X-Git-Url: https://git.decadent.org.uk/gitweb/?p=nfs-utils.git;a=blobdiff_plain;f=support%2Finclude%2Fha-callout.h;h=efb70fb28378fe0e02b9eabb4f5515ed1c6eb245;hp=707d51bcb8dae803688449e690f1da7ef47c0fb2;hb=refs%2Ftags%2Fnfs-utils-1-0-7-pre2;hpb=af93e0306d87bba3f703386fd6390e9bf8e76816 diff --git a/support/include/ha-callout.h b/support/include/ha-callout.h index 707d51b..efb70fb 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; + newact.sa_flags = 0; + sigemptyset(&newact.sa_mask); + sigaction(SIGCHLD, &newact, &oldact); pid = fork(); switch (pid) { case 0: execl(ha_callout_prog, ha_callout_prog, @@ -39,9 +50,9 @@ ha_callout(char *event, char *arg1, char *arg2, int arg3) exit(2); case -1: perror("fork"); break; - default: ret = waitpid(pid, NULL, 0); + default: pid = waitpid(pid, &ret, 0); } - + sigaction(SIGCHLD, &oldact, &newact); #ifdef dprintf dprintf(N_DEBUG, "ha callout returned %d\n", WEXITSTATUS(ret)); #else