From: Lennart Poettering Date: Tue, 2 Apr 2019 08:10:02 +0000 (+0200) Subject: tty-ask-password: simplify signal handler installation X-Git-Tag: v242-rc1~10^2~1 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d850296466c502106e680a2a5c07d3aa3213b97f;p=thirdparty%2Fsystemd.git tty-ask-password: simplify signal handler installation --- diff --git a/src/tty-ask-password-agent/tty-ask-password-agent.c b/src/tty-ask-password-agent/tty-ask-password-agent.c index 4633779837a..17cf35126fb 100644 --- a/src/tty-ask-password-agent/tty-ask-password-agent.c +++ b/src/tty-ask-password-agent/tty-ask-password-agent.c @@ -697,23 +697,24 @@ static int parse_argv(int argc, char *argv[]) { */ static int ask_on_this_console(const char *tty, pid_t *ret_pid, char *argv[]) { _cleanup_strv_free_ char **arguments = NULL; - struct sigaction sig = { + static const struct sigaction sigchld = { .sa_handler = nop_signal_handler, .sa_flags = SA_NOCLDSTOP | SA_RESTART, }; + static const struct sigaction sighup = { + .sa_handler = SIG_DFL, + .sa_flags = SA_RESTART, + }; int r; arguments = strv_copy(argv); if (!arguments) return log_oom(); + assert_se(sigaction(SIGCHLD, &sigchld, NULL) >= 0); + assert_se(sigaction(SIGHUP, &sighup, NULL) >= 0); assert_se(sigprocmask_many(SIG_UNBLOCK, NULL, SIGHUP, SIGCHLD, -1) >= 0); - assert_se(sigaction(SIGCHLD, &sig, NULL) >= 0); - - sig.sa_handler = SIG_DFL; - assert_se(sigaction(SIGHUP, &sig, NULL) >= 0); - r = safe_fork("(sd-passwd)", FORK_RESET_SIGNALS|FORK_LOG, ret_pid); if (r < 0) return r;