[Previous] [Contents] [Next]

daemon()

Run a process in the background

Synopsis:

#include <stdlib.h>

int daemon( int nochdir, 
            int noclose );

Library:

libc

Description:

The daemon() function allows programs to detach themselves from the controlling terminal and run in the background as system daemons.

nochdir
Unless nochdir is nonzero, the procmgr_daemon() function changes the current working directory to the root (/).
noclose
Unless noclose is nonzero, the procmgr_daemon() function redirects standard input, standard output and standard error to /dev/null.

This function calls procmgr_daemon().

Returns:

Zero for success, or -1 if an error occurs (errno is set).

Classification:

Legacy Unix

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

fork(), setsid()


[Previous] [Contents] [Next]