From: Roy Marples Date: Fri, 15 May 2020 14:56:47 +0000 (+0100) Subject: dhcpcd: allow sigpipe in scripts. X-Git-Tag: v9.1.0~60 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=529a6092e6ada5a185cb2baefdf509a6c24678ec;p=thirdparty%2Fdhcpcd.git dhcpcd: allow sigpipe in scripts. --- diff --git a/src/dhcpcd.c b/src/dhcpcd.c index e9a3877b..3f5c35d5 100644 --- a/src/dhcpcd.c +++ b/src/dhcpcd.c @@ -85,6 +85,11 @@ const int dhcpcd_signals[] = { SIGUSR2, }; const size_t dhcpcd_signals_len = __arraycount(dhcpcd_signals); + +const int dhcpcd_signals_ignore[] = { + SIGPIPE, +}; +const size_t dhcpcd_signals_ignore_len = __arraycount(dhcpcd_signals_ignore); #endif #define IF_UPANDRUNNING(a) \ @@ -1784,6 +1789,7 @@ main(int argc, char **argv) #ifdef USE_SIGNALS int sig = 0; const char *siga = NULL; + size_t si; #endif /* Test for --help and --version */ @@ -2040,8 +2046,8 @@ printpidfile: } #ifdef USE_SIGNALS - /* Ignore SIGPIPE, prefer EPIPE. */ - signal(SIGPIPE, SIG_IGN); + for (si = 0; si < dhcpcd_signals_ignore_len; si++) + signal(dhcpcd_signals_ignore[i], SIG_IGN); /* Save signal mask, block and redirect signals to our handler */ if (eloop_signal_set_cb(ctx.eloop, diff --git a/src/dhcpcd.h b/src/dhcpcd.h index e0044c22..5d896738 100644 --- a/src/dhcpcd.h +++ b/src/dhcpcd.h @@ -248,6 +248,8 @@ struct dhcpcd_ctx { #ifdef USE_SIGNALS extern const int dhcpcd_signals[]; extern const size_t dhcpcd_signals_len; +extern const int dhcpcd_signals_ignore[]; +extern const size_t dhcpcd_signals_ignore_len; #endif int dhcpcd_ifafwaiting(const struct interface *); diff --git a/src/script.c b/src/script.c index 186b6e05..56f6cad3 100644 --- a/src/script.c +++ b/src/script.c @@ -108,6 +108,8 @@ script_exec(char *const *argv, char *const *env) posix_spawnattr_setsigmask(&attr, &defsigs); for (i = 0; i < dhcpcd_signals_len; i++) sigaddset(&defsigs, dhcpcd_signals[i]); + for (i = 0; i < dhcpcd_signals_ignore_len; i++) + sigaddset(&defsigs, dhcpcd_signals_ignore[i]); posix_spawnattr_setsigdefault(&attr, &defsigs); #endif errno = 0;