mirror of
https://github.com/znc/znc.git
synced 2026-03-28 17:42:41 +01:00
Handle SIGCHLD for collecting zombie processes
The old code failed to collect the following command to *shell correctly: exec > /dev/null 2> /dev/null < /dev/null ; sleep 10 The timeout in CExecSock::close2() was over before the child processes exited and a zombie was left behind. Plus we used some ugly busy looping while waiting for the child to exit. Using SIGCHLD for collecting zombies is soooooo much nicer. git-svn-id: https://znc.svn.sourceforge.net/svnroot/znc/trunk@1504 726aef4b-f618-498e-8847-2d620e286838
This commit is contained in:
@@ -556,11 +556,6 @@ int CExecSock::popen2(int & iReadFD, int & iWriteFD, const CString & sCommand) {
|
||||
void CExecSock::close2(int iPid, int iReadFD, int iWriteFD) {
|
||||
close(iReadFD);
|
||||
close(iWriteFD);
|
||||
u_int iNow = time(NULL);
|
||||
while (waitpid(iPid, NULL, WNOHANG) == 0) {
|
||||
if ((time(NULL) - iNow) > 5)
|
||||
break; // giveup
|
||||
usleep(100);
|
||||
}
|
||||
// If a zombie is left behind, SIGCHLD will handle it
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user