Browse Source

daemon-mode: add sleep() loop to prevent defunct child process, call setsid() in child

miguelfreitas
tcatm 14 years ago
parent
commit
1c09a4adb2
  1. 8
      init.cpp

8
init.cpp

@ -236,6 +236,10 @@ bool AppInit2(int argc, char* argv[]) @@ -236,6 +236,10 @@ bool AppInit2(int argc, char* argv[])
}
if (pid > 0)
return true;
pid_t sid = setsid();
if (sid < 0)
fprintf(stderr, "Error: setsid() returned %d errno %d\n", sid, errno);
}
#endif
@ -467,5 +471,9 @@ bool AppInit2(int argc, char* argv[]) @@ -467,5 +471,9 @@ bool AppInit2(int argc, char* argv[])
SetStartOnSystemStartup(true);
#endif
if (fDaemon)
while (!fShutdown)
Sleep(5000);
return true;
}

Loading…
Cancel
Save