Handle signals TERM, QUIT and CHLD for zombies

This commit is contained in:
Martin Duquesnoy
2012-01-29 04:24:28 +01:00
parent 69391afed8
commit 25dec6073c
2 changed files with 31 additions and 9 deletions

View File

@@ -108,16 +108,12 @@ spawn(const char *format, ...)
if(!(sh = getenv("SHELL")) || sh[0] != '/')
sh = "/bin/sh";
if((pid = fork()) == 0)
if(!(pid = fork()))
{
if((pid = fork()) == 0)
{
setsid();
if (execl(sh, sh, "-c", cmd, (char*)NULL) == -1)
warnl("execl(sh -c %s)", cmd);
exit(EXIT_FAILURE);
}
exit(EXIT_SUCCESS);
setsid();
if (execl(sh, sh, "-c", cmd, (char*)NULL) == -1)
warnl("execl(sh -c %s)", cmd);
exit(EXIT_FAILURE);
}
else if (pid == -1)
warnl("fork");