We can't mask ignored signal, so install dummy signal hander for SIGCHLD before

masking it.

This fixes bogus reports about hooks running for too long and other problems
related to garbage-collecting child processes.

Reported by:	Mikolaj Golub <to.my.trociny@gmail.com>
MFC after:	3 days
This commit is contained in:
Pawel Jakub Dawidek 2010-10-04 21:41:18 +00:00
parent 7b039740b7
commit 41013c0b21

View File

@ -685,6 +685,12 @@ main_loop(void)
}
}
static void
dummy_sighandler(int sig __unused)
{
/* Nothing to do. */
}
int
main(int argc, char *argv[])
{
@ -743,6 +749,11 @@ main(int argc, char *argv[])
cfg = yy_config_parse(cfgpath, true);
assert(cfg != NULL);
/*
* Because SIGCHLD is ignored by default, setup dummy handler for it,
* so we can mask it.
*/
PJDLOG_VERIFY(signal(SIGCHLD, dummy_sighandler) != SIG_ERR);
PJDLOG_VERIFY(sigemptyset(&mask) == 0);
PJDLOG_VERIFY(sigaddset(&mask, SIGHUP) == 0);
PJDLOG_VERIFY(sigaddset(&mask, SIGINT) == 0);