You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
530 B
Rust
15 lines
530 B
Rust
use std::io::prelude::*;
|
|
use std::process::{Command, Stdio};
|
|
fn main() {
|
|
// Spawn the `ps` command
|
|
let process = match Command::new("ps").stdout(Stdio::piped()).spawn() {
|
|
Err(err) => panic!("couldn't spawn ps: {}", err),
|
|
Ok(process) => process,
|
|
};
|
|
let mut ps_output = String::new();
|
|
match process.stdout.unwrap().read_to_string(&mut ps_output) {
|
|
Err(err) => panic!("couldn't read ps stdout: {}", err),
|
|
Ok(_) => print!("ps output from child process is:\n{}", ps_output),
|
|
}
|
|
}
|