| 28 |
#include <sys/stat.h> |
#include <sys/stat.h> |
| 29 |
#include <unistd.h> |
#include <unistd.h> |
| 30 |
|
|
| 31 |
void init_daemon(void) |
int init_daemon(void) |
| 32 |
{ |
{ |
| 33 |
int pid; |
int pid; |
| 34 |
|
|
| 36 |
|
|
| 37 |
if (pid > 0) // Parent process |
if (pid > 0) // Parent process |
| 38 |
{ |
{ |
| 39 |
exit(0); |
_exit(0); |
| 40 |
} |
} |
| 41 |
else if (pid < 0) // Error |
else if (pid < 0) // error |
| 42 |
{ |
{ |
| 43 |
exit(1); |
_exit(pid); |
| 44 |
} |
} |
| 45 |
|
|
| 46 |
// Child process |
// Child process |
| 50 |
|
|
| 51 |
if (pid > 0) // Parent process |
if (pid > 0) // Parent process |
| 52 |
{ |
{ |
| 53 |
exit(0); |
_exit(0); |
| 54 |
} |
} |
| 55 |
else if (pid < 0) // Error |
else if (pid < 0) // error |
| 56 |
{ |
{ |
| 57 |
exit(1); |
_exit(pid); |
| 58 |
} |
} |
| 59 |
|
|
| 60 |
// Child process |
// Child process |
| 61 |
umask(022); |
umask(022); |
| 62 |
|
|
| 63 |
return; |
return 0; |
| 64 |
} |
} |
| 65 |
|
|
| 66 |
int load_conf(const char *conf_file) |
int load_conf(const char *conf_file) |