root/tags/omega-1.0.0-rc2/tools/daemon/daemon_init.c

Revision 154, 318 bytes (checked in by malte, 2 years ago)
Line 
1
2#include "daemon_init.h"
3
4void daemon_init(const char *pname, int facility)
5{
6
7        int i;
8        pid_t pid;
9
10        if ((pid = fork()) != 0)
11                exit(0);
12
13        setsid();
14
15        signal(SIGHUP, SIG_IGN);
16
17        if ((pid = fork()) != 0)
18                exit(0);
19
20        chdir("/");
21
22        umask(0);
23
24        for(i = 0; i < 64; i++)
25        close(i);
26
27        openlog(pname, LOG_PID, facility);
28
29}
Note: See TracBrowser for help on using the browser.