diff --git a/crates/nu-command/src/system/ps.rs b/crates/nu-command/src/system/ps.rs index 86ad0d6979..c87f72e050 100644 --- a/crates/nu-command/src/system/ps.rs +++ b/crates/nu-command/src/system/ps.rs @@ -1,11 +1,20 @@ #[cfg(windows)] use itertools::Itertools; +#[cfg(all( + unix, + not(target_os = "macos"), + not(target_os = "windows"), + not(target_os = "android"), + not(target_os = "ios") +))] +use nu_protocol::Span; use nu_protocol::{ ast::Call, engine::{Command, EngineState, Stack}, Category, Example, IntoInterruptiblePipelineData, PipelineData, Record, ShellError, Signature, Type, Value, }; + use std::time::Duration; #[derive(Clone)] @@ -101,6 +110,40 @@ fn run_ps(engine_state: &EngineState, call: &Call) -> Result t, + Err(_) => { + // If we can't get the start time, just use the current time + chrono::Local::now() + } + }; + record.push("start_time", Value::date(proc_start.into(), span)); + record.push("user_id", Value::int(proc.curr_proc.owner() as i64, span)); + // These work and may be helpful, but it just seemed crowded + // record.push("group_id", Value::int(proc_stat.pgrp as i64, span)); + // record.push("session_id", Value::int(proc_stat.session as i64, span)); + // This may be helpful for ctrl+z type of checking, once we get there + // record.push("tpg_id", Value::int(proc_stat.tpgid as i64, span)); + record.push("priority", Value::int(proc_stat.priority, span)); + record.push("process_threads", Value::int(proc_stat.num_threads, span)); + } #[cfg(windows)] { //TODO: There's still more information we can cram in there if we want to