From: neilbrown Date: Fri, 10 Dec 2004 01:15:45 +0000 (+0000) Subject: ha-callout ands sigchld X-Git-Tag: nfs-utils-1-0-7-pre2~1 X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=commitdiff_plain;h=b3e11098b1eaf65caae2fa0787e9839ce7d5e818 ha-callout ands sigchld --- diff --git a/ChangeLog b/ChangeLog index fed8afe..9562844 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,8 @@ 2004-12-06 Paul Clements * support/include/ha-callout.h: get return status from waitpid correctly. + * support/include/ha-callout.h: don't ignore SIGCHLD while waiting + for a callout to complete. * utils/statd/statd.c(sigusr): print current start when re-reading notify list due to SIGUSR1 * utils/statd/svc_run.c(my_svc_run): call change_state when diff --git a/support/include/ha-callout.h b/support/include/ha-callout.h index 8acf0de..64a430d 100644 --- a/support/include/ha-callout.h +++ b/support/include/ha-callout.h @@ -14,6 +14,7 @@ #define HA_CALLOUT_H #include +#include extern char *ha_callout_prog; @@ -23,12 +24,22 @@ ha_callout(char *event, char *arg1, char *arg2, int arg3) char buf[16]; /* should be plenty */ pid_t pid; int ret = -1; + struct sigaction oldact, newact; if (!ha_callout_prog) /* HA callout is not enabled */ return; sprintf(buf, "%d", arg3); + /* many daemons ignore SIGCHLD as tcpwrappers will + * fork a child to do logging. We need to wait + * for a child here, so we need to un-ignore + * SIGCHLD temporarily + */ + newact.sa_handler = SIG_DFL; + newacc.sa_flags = 0; + sigemptyset(&newact.sa_mask); + sigaction(SIGCHLD, &newact, &oldact); pid = fork(); switch (pid) { case 0: execl(ha_callout_prog, ha_callout_prog, @@ -41,7 +52,7 @@ ha_callout(char *event, char *arg1, char *arg2, int arg3) break; default: pid = waitpid(pid, &ret, 0); } - + sigaction(SIGCHLD, &oldact, &newact); #ifdef dprintf dprintf(N_DEBUG, "ha callout returned %d\n", WEXITSTATUS(ret)); #else