[−][src]Module pwner::process
This module holds the std implementation of a process.
All interactions are blocking, including the dropping of child processes (on *nix platforms).
Spawning an owned tokio process
use std::process::Command; use pwner::Spawner; Command::new("ls").spawn_owned().expect("ls command failed to start");
Reading from the process
use std::io::Read; use std::process::Command; use pwner::Spawner; let mut child = Command::new("ls").spawn_owned()?; let mut output = String::new(); child.read_to_string(&mut output)?;
Writing to the process
use std::io::{Read, Write}; use std::process::Command; use pwner::Spawner; let mut child = Command::new("cat").spawn_owned()?; child.write_all(b"hello\n")?; let mut buffer = [0_u8; 10]; child.read(&mut buffer)?;
Graceful dropping
Note: Only available on *nix platforms.
When the owned process gets dropped, Process
will try to
kill it gracefully by sending a SIGINT
and checking, without blocking, if the child has diesd.
If the child is still running, it will block for 2seconds. If the process still doesn't die,
a SIGTERM
is sent and another chance is given, until finally a SIGKILL
is sent.
Structs
Process | An implementation of |
Enums
ReadSource | Possible sources to read from |