|
server 0.0.1
basicserverinfrastructure
|
#include <stdio.h>#include <unistd.h>#include <stdlib.h>
Go to the source code of this file.
Functions | |
| void | daemonize (void) |
| void daemonize | ( | void | ) |
Definition at line 6 of file daemonize.c.
{
pid_t pid;
if (0 > ((pid = fork()))) {
perror("deamoinze[fork]");
exit(EXIT_FAILURE);
} else if (0 != pid) {
exit(EXIT_SUCCESS);
}
/* make new child session leader */
setsid();
/* connect all standard streams to /dev/null */
stderr = freopen("/dev/null", "w", stderr);
stdin = freopen("/dev/null", "r", stdin);
stdout = freopen("/dev/null", "w", stdout);
}