Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/d/daemon.html on line 1

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/d/daemon.html on line 1

Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/d/daemon.html on line 8

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/d/daemon.html on line 8

daemon()

Run a process in the background

Synopsis:

#include <stdlib.h>

int daemon( int nochdir, 
            int noclose );

Arguments:

nochdir
If this argument is 0, the current working directory is changed to the root directory (/).
noclose
If this argument is 0, standard input, standard output, and standard error are redirected to /dev/null.

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

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

This function calls fork() and setsid().


Note: The controlling terminal behaves as in Unix System V, Release 4. An open() on a terminal device not already associated with another session causes the device to become the controlling terminal for that process.

The High Availability Manager can see death messages only from tasks that are running in session 1, and daemon() doesn't put the caller into that session; use procmgr_daemon() instead if you want to use your application with the HAM.


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 No

Caveats:

Currently, daemon() is supported only in single-threaded applications. If you create a thread and then call daemon(), the function returns -1 and sets errno to ENOSYS.

See also:

fork(), procmgr_daemon(), setsid()


Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/d/daemon.html on line 152

Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/d/daemon.html on line 152