Skip to main content

Module daemon

Module daemon 

Source
Expand description

Detaching from the terminal, for -f.

This has to run before the tokio runtime is created: fork(2) does not carry threads into the child, so a runtime built beforehand would be left with worker threads that no longer exist.

autossh calls daemon(3) (autossh.c:448). macOS deprecates that function, so rash performs the same steps by hand — daemon(0, 0) means “do chdir to /” and “do close the standard descriptors”.

Functions§

daemonize
Fork twice, start a new session, move to /, and point the standard descriptors at /dev/null.