Call setsid() after forking

This way we get rid of our controlling terminal.
Now ZNC won't stay in the session of the shell anymore...


git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1036 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
psychon
2008-05-04 14:08:10 +00:00
parent 3775748270
commit 311d20495f
+7
View File
@@ -216,6 +216,7 @@ int main(int argc, char** argv) {
}
if (iPid > 0) {
// We are the parent. We are done and will go to bed.
CUtils::PrintStatus(true, "[pid: " + CString(iPid) + "]");
pZNC->WritePidFile(iPid);
@@ -229,6 +230,12 @@ int main(int argc, char** argv) {
close(2); open("/dev/null", O_WRONLY);
CUtils::SetStdoutIsTTY(false);
// We are the child. There is no way we can be a process group
// leader, thus setsid() must succeed.
setsid();
// Now we are in our own process group and session (no controlling
// terminal). We are independent!
#endif
struct sigaction sa;