aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNIIBE Yutaka <[email protected]>2018-03-19 07:36:30 +0000
committerNIIBE Yutaka <[email protected]>2018-03-19 07:36:30 +0000
commit11bbd99477ef5ba5b7db0c17607b10af03c68afb (patch)
treec46f154022214c802ecfd6bd8fd599766e6ed88e
parentscd: Better user interaction for factory-reset. (diff)
downloadgnupg-11bbd99477ef5ba5b7db0c17607b10af03c68afb.tar.gz
gnupg-11bbd99477ef5ba5b7db0c17607b10af03c68afb.zip
scd: signal mask should be set just after npth_init.
* scd/scdaemon.c (setup_signal_mask): New. (main): Call setup_signal_mask. (handle_connections): Remove signal mask setup. -- For new thread, signal mask is inherited by thread creation. Thus, it is best to setup signal mask just after npth_init. Signed-off-by: NIIBE Yutaka <[email protected]>
-rw-r--r--scd/scdaemon.c28
1 files changed, 17 insertions, 11 deletions
diff --git a/scd/scdaemon.c b/scd/scdaemon.c
index e63aca72f..8f8a02619 100644
--- a/scd/scdaemon.c
+++ b/scd/scdaemon.c
@@ -393,7 +393,21 @@ cleanup (void)
}
}
-
+static void
+setup_signal_mask (void)
+{
+#ifndef HAVE_W32_SYSTEM
+ npth_sigev_init ();
+ npth_sigev_add (SIGHUP);
+ npth_sigev_add (SIGUSR1);
+ npth_sigev_add (SIGUSR2);
+ npth_sigev_add (SIGINT);
+ npth_sigev_add (SIGCONT);
+ npth_sigev_add (SIGTERM);
+ npth_sigev_fini ();
+ main_thread_pid = getpid ();
+#endif
+}
int
main (int argc, char **argv )
@@ -744,6 +758,7 @@ main (int argc, char **argv )
#endif
npth_init ();
+ setup_signal_mask ();
gpgrt_set_syscall_clamp (npth_unprotect, npth_protect);
/* If --debug-allow-core-dump has been given we also need to
@@ -884,6 +899,7 @@ main (int argc, char **argv )
/* This is the child. */
npth_init ();
+ setup_signal_mask ();
gpgrt_set_syscall_clamp (npth_unprotect, npth_protect);
/* Detach from tty and put process into a new session. */
@@ -1290,16 +1306,6 @@ handle_connections (int listen_fd)
events[0] = the_event = h2;
}
}
-#else
- npth_sigev_init ();
- npth_sigev_add (SIGHUP);
- npth_sigev_add (SIGUSR1);
- npth_sigev_add (SIGUSR2);
- npth_sigev_add (SIGINT);
- npth_sigev_add (SIGCONT);
- npth_sigev_add (SIGTERM);
- npth_sigev_fini ();
- main_thread_pid = getpid ();
#endif
FD_ZERO (&fdset);