slave: re-use ‘struct sigaction’ variable when resetting SIGHUP+SIGPIPE

This commit is contained in:
Daniel Eklöf 2021-12-18 23:22:52 +01:00
parent fb488b6162
commit 027603cbb8
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -275,11 +275,13 @@ slave_spawn(int ptmx, int argc, const char *cwd, char *const *argv,
}
/* Restore signal mask, and SIG_IGN'd signals */
const struct sigaction dfl = {.sa_handler = SIG_DFL};
sigset_t mask;
sigemptyset(&mask);
if (sigprocmask(SIG_SETMASK, &mask, NULL) < 0 ||
sigaction(SIGHUP, &(struct sigaction){.sa_handler = SIG_DFL}, NULL) < 0 ||
sigaction(SIGPIPE, &(struct sigaction){.sa_handler = SIG_DFL}, NULL) < 0)
sigaction(SIGHUP, &dfl, NULL) < 0 ||
sigaction(SIGPIPE, &dfl, NULL) < 0)
{
const int errno_copy = errno;
LOG_ERRNO_P(errno, "failed to restore signals");