From 165945a8aee6b68a47e648bf038f4644a0b1ed93 Mon Sep 17 00:00:00 2001
From: bjorn3 <17426603+bjorn3@users.noreply.github.com>
Date: Fri, 11 Oct 2024 10:49:39 +0200
Subject: [PATCH] Implement the process info functions for FreeBSD
---
src/system/mod.rs | 119 ++++++++++++++++++++++++++++++++++++++++++++-
src/system/time.rs | 13 ++++-
2 files changed, 130 insertions(+), 2 deletions(-)
diff --git a/src/system/mod.rs b/src/system/mod.rs
index a8251b4d4..7061ccbcc 100644
--- a/src/system/mod.rs
+++ b/src/system/mod.rs
@@ -1,5 +1,7 @@
use core::fmt;
// TODO: remove unused attribute when system is cleaned up
+#[cfg(target_os = "linux")]
+use std::str::FromStr;
use std::{
collections::BTreeSet,
ffi::{c_uint, CStr, CString},
@@ -11,7 +13,6 @@ use std::{
unix::{self, prelude::OsStrExt},
},
path::{Path, PathBuf},
- str::FromStr,
};
use crate::{
@@ -562,6 +563,7 @@ pub enum WithProcess {
}
impl WithProcess {
+ #[cfg(target_os = "linux")]
fn to_proc_string(&self) -> String {
match self {
WithProcess::Current => "self".into(),
@@ -620,6 +622,7 @@ impl Process {
/// Returns the device identifier of the TTY device that is currently
/// attached to the given process
+ #[cfg(target_os = "linux")]
pub fn tty_device_id(pid: WithProcess) -> std::io::Result