[Previous] [Contents] [Next]

procmgr_daemon()

Run a process in the background

Synopsis:

#include <sys/procmgr.h>

int procmgr_daemon( int status,
                    unsigned flags );

Library:

libc

Description:

The function procmgr_daemon() function lets programs detach themselves from the controlling terminal and run in the background as system daemons. This also puts the caller into session 1. The argument status is returned to the parent process as if exit() were called; the returned value is normally EXIT_SUCCESS.

The flags argument

Flags currently defined (in <sys/procmgr.h>) are:

PROCMGR_DAEMON_NOCHDIR
Unless this flag is set, procmgr_daemon() changes the current working directory to the root "/".
PROCMGR_DAEMON_NOCLOSE
Unless this flag is set, procmgr_daemon() closes all fd's other than standard input, standard output and standard error.
PROCMGR_DAEMON_NODEVNULL
Unless this flag is set, procmgr_daemon() redirects standard input, standard output and standard error to /dev/null.
PROCMGR_DAEMON_KEEPUMASK
Unless this flag is set, procmgr_daemon() sets the umask to 0 (zero).

Returns:

A nonnegative integer, or -1 if an error occurs.

Classification:

QNX 6

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

[Previous] [Contents] [Next]