Run a process in the background
#include <sys/procmgr.h> int procmgr_daemon( int status, unsigned flags );
libc
Use the -l c option to qcc to link against this library. This library is usually included automatically.
The 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 High Availability Manager (HAM) automatically monitors processes detached using procmgr_daemon() because they're in session 1. For more information, see the High Availability Framework Developer's Guide.
If procmgr_daemon() is called without PROCMGR_DAEMON_NOCLOSE set in flags and fails, then the state of file descriptors 0, 1, and 2 (STDIN_FILENO, STDOUT_FILENO, and STDERR_FILENO) is undefined.
The argument status is returned to the parent process as if exit() were called; the returned value is normally EXIT_SUCCESS.
A nonnegative integer, or -1 if an error occurs (errno is set).
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Yes |
Thread | Yes |