From 60e130eb881caf1d9390597542add75adeacc2d2 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 13 May 2024 18:56:55 -0400 Subject: [PATCH 1/3] Add FreeBSD process helper support --- pueue_lib/src/process_helper/freebsd.rs | 15 +++++++++++++++ pueue_lib/src/process_helper/mod.rs | 1 + 2 files changed, 16 insertions(+) create mode 100644 pueue_lib/src/process_helper/freebsd.rs diff --git a/pueue_lib/src/process_helper/freebsd.rs b/pueue_lib/src/process_helper/freebsd.rs new file mode 100644 index 00000000..8b6ac533 --- /dev/null +++ b/pueue_lib/src/process_helper/freebsd.rs @@ -0,0 +1,15 @@ +use std::path::Path; + +/// Check, whether a specific process is exists or not +pub fn process_exists(pid: u32) -> bool { + return Path::new(&format!("/proc/{}", pid)).is_dir(); +} + +#[cfg(test)] +pub mod tests { + /// Get all processes in a process group + pub fn get_process_group_pids(pgrp: i32) -> Vec { + /// TODO + return { }; + } +} diff --git a/pueue_lib/src/process_helper/mod.rs b/pueue_lib/src/process_helper/mod.rs index 208ff411..624ec5bf 100644 --- a/pueue_lib/src/process_helper/mod.rs +++ b/pueue_lib/src/process_helper/mod.rs @@ -21,6 +21,7 @@ use command_group::Signal; #[cfg_attr(target_os = "linux", path = "linux.rs")] #[cfg_attr(target_vendor = "apple", path = "apple.rs")] #[cfg_attr(target_os = "windows", path = "windows.rs")] +#[cfg_attr(target_os = "freebsd", path = "freebsd.rs")] mod platform; pub use self::platform::*; From 185df7791eeb3cceb8bdae310155d8abae6e8193 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Mon, 13 May 2024 19:00:45 -0400 Subject: [PATCH 2/3] Document FreeBSD process helper addition --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 29dfd36b..c4a8edc9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), ### Added - Nushell autocompletion script [#527](https://github.com/Nukesor/pueue/pull/527) +- Add FreeBSD process helper to facilitate FreeBSD builds ## \[3.4.0\] - 2024-03-22 From cffb17c819769bf7ad711f0365408fb3109bc8d4 Mon Sep 17 00:00:00 2001 From: Ryan Steinmetz Date: Tue, 14 May 2024 10:30:31 -0400 Subject: [PATCH 3/3] Move libproc/procfs support fo linux/macos only (removing FreeBSD) --- pueue/Cargo.toml | 4 +++- pueue_lib/Cargo.toml | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pueue/Cargo.toml b/pueue/Cargo.toml index d3b9c712..8f027966 100644 --- a/pueue/Cargo.toml +++ b/pueue/Cargo.toml @@ -65,5 +65,7 @@ crossterm = { version = "0.27", default-features = false, features = ["windows"] # Test specific dev-dependencies [target.'cfg(any(target_os = "linux", target_os = "freebsd"))'.dependencies] whoami = "1" -procfs = { version = "0.16", default-features = false } +# Test specific Linux dev-dependencies +[target.'cfg(target_os = "linux")'.dependencies] +procfs = { version = "0.16", default-features = false } diff --git a/pueue_lib/Cargo.toml b/pueue_lib/Cargo.toml index 01e488bc..bce94a6f 100644 --- a/pueue_lib/Cargo.toml +++ b/pueue_lib/Cargo.toml @@ -67,9 +67,11 @@ winapi = { version = "0.3", features = [ # Unix [target.'cfg(unix)'.dependencies] -libproc = "0.14.6" whoami = "1" +[target.'cfg(any(target_os = "linux", target_os = "macos"))'.dependencies] +libproc = "0.14.6" + # Linux only [target.'cfg(target_os = "linux")'.dependencies] procfs = { version = "0.16", default-features = false }