double fork to daemonize
This commit is contained in:
@@ -62,6 +62,13 @@ void daemonize(){
|
|||||||
|
|
||||||
setsid();
|
setsid();
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Double fork method
|
||||||
|
*/
|
||||||
|
pid = fork();
|
||||||
|
if(pid < 0) exit(1);
|
||||||
|
if(pid > 0) exit(0);
|
||||||
|
|
||||||
for(i = getdtablesize(); i >= 0; --i) close(i);
|
for(i = getdtablesize(); i >= 0; --i) close(i);
|
||||||
|
|
||||||
lfp = open("/dev/null",O_RDWR);
|
lfp = open("/dev/null",O_RDWR);
|
||||||
|
|||||||
Reference in New Issue
Block a user