mirror of
https://github.com/znc/znc.git
synced 2026-08-06 08:52:57 +02:00
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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user