[−][src]Crate fork
Library for creating a new process detached from the controling terminal (daemon)
Example:
use fork::{daemon, Fork}; use std::process::Command; fn main() { if let Ok(Fork::Child) = daemon(true, true) { Command::new("sleep") .arg("300") .output() .expect("failed to execute process"); } }
Enums
| Fork | Fork result |
Functions
| chdir | Upon successful completion, 0 shall be returned. Otherwise, -1 shall be returned, the current working directory shall remain unchanged, and errno shall be set to indicate the error. |
| close_fd | close file descriptors stdin,stdout,stderr |
| daemon | The daemon function is for programs wishing to detach themselves from the controlling terminal and run in the background as system daemons. |
| fork | Upon successful completion, fork() returns a value of 0 to the child process and returns the process ID of the child process to the parent process. Otherwise, a value of -1 is returned to the parent process, no child process is created. |
| setsid | Upon successful completion, the setsid() system call returns the value of the process group ID of the new process group, which is the same as the process ID of the calling process. If an error occurs, setsid() returns -1 |