pid_t leavehome( void );
This function performs the following sequence of actions.
int restart_files( void );
int restart_these_files( const char *in_name,
const char *out_name,
const char *err_name );
This pair of functions performs an freopen on the standard
I/O streams stdin, stdout & stderr.
The restart_files function gets the filenames for the streams by evaluating the configuration file parameters STDIN, STDOUT & STDERR. If the evaluations produce NULL or empty string then the default value of /dev/null is used.
The restart_these_files function behaves as above with the exception that the file names are explicitly provided. As with restart_files should any parameter be NULL or an empty string then the value /dev/null is used.
int init_signalling( void );
int check_signalling( void );
int allow_sysint( void );
int deny_sysint( void );
The init_signalling routine sets up a standard handler for
the following signals
The check_signalling routine returns the value of any stored signal received. The value is also cleared.
The allow_sysint routine saves a copy of the signal handler state for the above listed signals and puts in place copies with the SA_RESTART flag cleared. This function only has effect once unless the deny_sysint function is called.
The deny_sysint routine takes the previously saved state of the signal handlers (saved via a call to allow_sysint) and restores them.
int mp_daemon_sleep( int how_long );
This function provides the facility to sleep for the supplied
number of seconds, but also to be woken if an interrupt occurs, or
if a process pipe exists when a character is received. It uses a
select call along with allow_sysint & deny_sysint.
int mp_daemon_loop( int(*poll_func)(int),
int(*u1_func)(int),
int(*u2_func)(int),
int(*int_func)(int),
int(*term_func)(int),
int flags );
The poll_func parameter must be a non-NULL pointer to a function taking an integer parameter, and returning an integer.
The next four parameters, u1_func, u2_func, int_func & term_func are similar function pointers but NULL may be supplied.
The flags parameter should be 0.
Note that because the functions are passed the value of the signal or 0 it is possible to use the same function for all of the parameters.