This module contains functions related to daemons.
void sld_daemon_daemonize |
( |
char * |
pid_file_name, |
|
|
char * |
runas_user, |
|
|
char * |
runas_group |
|
) |
| |
Executes code contained in sld_daemon_start() as a background process using the specified options.
- Parameters
-
pid_file_name | path to PID (process ID) file |
runas_user | user account to run process as – use NULL to run the process as the current user |
runas_group | group to run process as – use NULL to run the process as the current primary group |
- Examples:
- daemon.c.
void sld_daemon_start |
( |
| ) |
|
Wrap code within this function to execute it as a background process.
{
for(;;)
{
do_something();
sleep(10);
}
}
- Examples:
- daemon.c.
pid_t sld_daemon_write_pid_file |
( |
char * |
pid_file_name | ) |
|
Writes the PID (process ID) to the specified file.
- Parameters
-
pid_file_name | path to PID (process ID) file |
- Returns
- PID (process ID) of running process