SIP-router core ::Module: SIP-router core. More...
#include <sys/types.h>#include <signal.h>#include <syslog.h>#include <errno.h>#include <string.h>#include <stdio.h>#include <stdlib.h>#include <sys/time.h>#include <sys/resource.h>#include <unistd.h>#include <pwd.h>#include <grp.h>#include "daemonize.h"#include "globals.h"#include "dprint.h"#include "signals.h"#include "cfg/cfg.h"
Go to the source code of this file.
Definition in file daemonize.c.
| void daemon_status_init | ( | void | ) |
Must be called before any other daemon_status function has a chance to run.
Definition at line 98 of file daemonize.c.
References daemon_status_fd.
| void daemon_status_no_wait | ( | void | ) |
Should be called after fork(), for each new process that doesn't use daemon_status_wait().
Definition at line 200 of file daemonize.c.
References daemon_status_fd.
Referenced by daemonize().

| void daemon_status_on_fork_cleanup | ( | ) |
Should be called after fork(), for each new process that _does_ _not_ use daemon_status_send() or daemon_status_wait().
Definition at line 182 of file daemonize.c.
References daemon_status_fd.
Referenced by fork_process().

| int daemon_status_pre_daemonize | ( | void | ) |
Must be called before forking. Typically the parent process will call daemon_status_wait() while one of the children will call daemon_status_send() at some point.
Definition at line 113 of file daemonize.c.
References daemon_status_fd.
Referenced by daemonize().

| int daemon_status_send | ( | char | status | ) |
| status | - status byte |
Definition at line 163 of file daemonize.c.
References daemon_status_fd.
| int daemon_status_wait | ( | char * | status | ) |
| status | - filled with the sent status (a char). |
Definition at line 135 of file daemonize.c.
References daemon_status_fd.
Referenced by daemonize().

| int daemonize | ( | char * | name, | |
| int | status_wait | |||
| ) |
| name | - daemon name used for logging (used when opening syslog). | |
| status_wait | - if 1 the original process will wait until it gets an exit code send using daemon_status_send(). |
Side-effects: sets own_pgid after becoming session leader (own process group).
Definition at line 269 of file daemonize.c.
References daemon_status_fd, daemon_status_no_wait(), daemon_status_pre_daemonize(), daemon_status_wait(), enable_dumpable(), log_facility, and log_stderr.

| int enable_dumpable | ( | void | ) |
Definition at line 213 of file daemonize.c.
Referenced by daemonize().

int daemon_status_fd[2] [static] |
This pipe is used to send the desired exit status to the initial process, that waits for it in the foreground. This way late errors preventing startup (e.g. during modules child inits or TCP late init) can still be reported back.
Definition at line 90 of file daemonize.c.
Referenced by daemon_status_init(), daemon_status_no_wait(), daemon_status_on_fork_cleanup(), daemon_status_pre_daemonize(), daemon_status_send(), daemon_status_wait(), and daemonize().
1.7.1