Better collection of zombie processes.

Note that there seems to be a deadlock if a process exits when there are
zombies around. Init also doesn't handle zombie children correctly as there
is sent no SIGCHLD signal yet.
This commit is contained in:
Jonas 'Sortie' Termansen 2012-09-08 19:25:13 +02:00
parent 07b3cc8e06
commit c9eb1b2cb3
2 changed files with 6 additions and 1 deletions

View File

@ -58,7 +58,9 @@ int runsystem()
return status;
}
return child();
int ret = child();
while ( 0 < waitpid(-1, NULL, WNOHANG) );
return ret;
}
int main(int argc, char* argv[])

View File

@ -79,6 +79,9 @@ int runcommandline(const char** tokens)
bool internal;
int internalresult;
readcmd:
// Collect any pending zombie processes.
while ( 0 < waitpid(-1, NULL, WNOHANG) );
cmdstart = cmdnext;
for ( cmdend = cmdstart; true; cmdend++ )
{