[−][src]Function fork::daemon
pub fn daemon(nochdir: bool, noclose: bool) -> Result<Fork, i32>
The daemon function is for programs wishing to detach themselves from the controlling terminal and run in the background as system daemons.
nochdir = false
, changes the current working directory to the root (/
).noclose = false
, will close standard input, standard output, and standard error
Example:
use fork::{daemon, Fork}; use std::process::Command; fn main() { if let Ok(Fork::Child) = daemon(false, false) { Command::new("sleep") .arg("3") .output() .expect("failed to execute process"); } }