summaryrefslogtreecommitdiff
path: root/src/tty-ask-password-agent/tty-ask-password-agent.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tty-ask-password-agent/tty-ask-password-agent.c')
-rw-r--r--src/tty-ask-password-agent/tty-ask-password-agent.c13
1 files changed, 7 insertions, 6 deletions
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 4633779837..17cf35126f 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;