pub fn daemonize(c: &mut Command) -> &mut Command {
    unsafe {
        c.pre_exec(|| {
            // daemonize(3) is deprecated on macOS 10.15. The replacement is not
            // yet clear, we may want to replace this with a manual double fork
            // setsid, etc.
            #[allow(deprecated)]
            // First argument: chdir(/)
            // Second argument: do not close stdio (we use stdio to write to the daemon log file)
            match libc::daemon(0, 1) {
                0 => Ok(()),
                x => Err(std::io::Error::from_raw_os_error(x)),
            }
        })
    }
}
/// daemonize adds a pre_exec to call daemon(3) causing the spawned
/// process to be forked again and detached from the controlling
/// terminal.
///
/// The implementation does not violate any of the constraints documented on
/// `Command::pre_exec`, and this code is expected to be safe.
///
/// This code may however cause a process hang if not used appropriately. Reading on
/// the subtleties of CLOEXEC, CLOFORK and forking multi-threaded programs will
/// provide ample background reading. For the sake of safe use, callers should work
/// to ensure that uses of `daemonize` occur early in the program lifecycle, before
/// many threads have been spawned, libraries have been used or files have been
/// opened that may introduce CLOEXEC behaviors that could cause EXTBUSY outcomes in
/// a Linux environment.
daemonize adds a pre_exec to call daemon(3) causing the spawned
process to be forked again and detached from the controlling
terminal.

The implementation does not violate any of the constraints documented on
`Command::pre_exec`, and this code is expected to be safe.

This code may however cause a process hang if not used appropriately. Reading on
the subtleties of CLOEXEC, CLOFORK and forking multi-threaded programs will
provide ample background reading. For the sake of safe use, callers should work
to ensure that uses of `daemonize` occur early in the program lifecycle, before
many threads have been spawned, libraries have been used or files have been
opened that may introduce CLOEXEC behaviors that could cause EXTBUSY outcomes in
a Linux environment.
daemonize adds a pre_exec to call daemon ( 3 ) causing the spawned process to be forked again and detached from the controlling terminal . The implementation does not violate any of the constraints documented on ` Command :: pre_exec ` and this code is expected to be safe . This code may however cause a process hang if not used appropriately . Reading on the subtleties of CLOEXEC CLOFORK and forking multi - threaded programs will provide ample background reading . For the sake of safe use callers should work to ensure that uses of ` daemonize ` occur early in the program lifecycle before many threads have been spawned libraries have been used or files have been opened that may introduce CLOEXEC behaviors that could cause EXTBUSY outcomes in a Linux environment .
pub fn daemonize(c: &mut Command) -> &mut Command {
    unsafe {
        c.pre_exec(|| {
            // daemonize(3) is deprecated on macOS 10.15. The replacement is not
            // yet clear, we may want to replace this with a manual double fork
            // setsid, etc.
            #[allow(deprecated)]
            // First argument: chdir(/)
            // Second argument: do not close stdio (we use stdio to write to the daemon log file)
            match libc::daemon(0, 1) {
                0 => Ok(()),
                x => Err(std::io::Error::from_raw_os_error(x)),
            }
        })
    }
}
pub fn daemonize ( c : & mut Command ) -> & mut Command { unsafe { c . pre_exec ( | | { // daemonize(3) is deprecated on macOS 10.15. The replacement is not // yet clear, we may want to replace this with a manual double fork // setsid, etc. # [ allow ( deprecated ) ] // First argument: chdir(/) // Second argument: do not close stdio (we use stdio to write to the daemon log file) match libc :: daemon ( 0 , 1 ) { 0 => Ok ( ( ) ) , x => Err ( std :: io :: Error :: from_raw_os_error ( x ) ) , } } ) } }
daemonize adds a pre_exec to call daemon(3) causing the spawned
process to be forked again and detached from the controlling
terminal.
daemonize adds a pre_exec to call daemon ( 3 ) causing the spawned process to be forked again and detached from the controlling terminal .
c
&mut Command
c
&mut Command