If we're running as init, install a signal handler for SIGCHLD.

PR:		bin/14729
Submitted by:	jhb
This commit is contained in:
Murray Stokely 2001-09-06 09:53:53 +00:00
parent 3da21d9f07
commit 810fd59fbb
2 changed files with 26 additions and 0 deletions

View File

@ -85,6 +85,18 @@ handle_intr(int sig)
restorescr(save);
}
/*
* Harvest children if we are init.
*/
static void
reap_children(int sig)
{
int errbak = errno;
while ( waitpid(-1, NULL, WNOHANG) > 0 )
;
errno = errbak;
}
/* Expand a file into a convenient location, nuking it each time */
static char *
expand(char *fname)
@ -166,6 +178,7 @@ systemInitialize(int argc, char **argv)
i = 0;
sysctlbyname("machdep.unaligned_print", NULL, 0, &i, sizeof(i));
#endif
signal(SIGCHLD, reap_children);
}
else {
char hname[256];

View File

@ -85,6 +85,18 @@ handle_intr(int sig)
restorescr(save);
}
/*
* Harvest children if we are init.
*/
static void
reap_children(int sig)
{
int errbak = errno;
while ( waitpid(-1, NULL, WNOHANG) > 0 )
;
errno = errbak;
}
/* Expand a file into a convenient location, nuking it each time */
static char *
expand(char *fname)
@ -166,6 +178,7 @@ systemInitialize(int argc, char **argv)
i = 0;
sysctlbyname("machdep.unaligned_print", NULL, 0, &i, sizeof(i));
#endif
signal(SIGCHLD, reap_children);
}
else {
char hname[256];