Crate fork

source · []
Expand description

Library for creating a new process detached from the controlling terminal (daemon).

Example:

use fork::{daemon, Fork};
use std::process::Command;

if let Ok(Fork::Child) = daemon(false, false) {
   Command::new("sleep")
       .arg("3")
       .output()
       .expect("failed to execute process");
}

Enums

Fork result

Functions

Change dir to / see chdir(2)

Close file descriptors stdin,stdout,stderr

The daemon function is for programs wishing to detach themselves from the controlling terminal and run in the background as system daemons.

Create a new child process see fork(2)

The process group of the current process see getgrp(2)

Create session and set process group ID see setsid(2)