Skip to main content

daemonize

Function daemonize 

Source
pub fn daemonize() -> Result<()>
Expand description

Daemonize the current process

This function:

  1. Forks the process (first fork)
  2. Creates a new session with setsid()
  3. Forks again (second fork) to prevent acquiring a controlling terminal
  4. Redirects stdin/stdout/stderr to /dev/null
  5. Changes working directory to /

Returns Ok(()) in the daemon process, or an error if daemonization fails. The parent process exits immediately.