From bf83678619dd0286f7a66f2ab02763751b0e8ca9 Mon Sep 17 00:00:00 2001 From: Hannes Reinecke Date: Mon, 26 Aug 2013 13:02:36 +0200 Subject: Block SIGALRM in ping.c MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ping depends on SIGALRM to exit eventually, so we need to mask it with UNBLOCK. Signed-off-by: Marcus Schäfer Signed-off-by: Hannes Reinecke --- ping.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ping.c b/ping.c index 3debd82..06cc369 100644 --- a/ping.c +++ b/ping.c @@ -452,6 +452,17 @@ main(int argc, char **argv) /* Create sockets */ enable_capability_raw(); + + /* + * ping depend on SIGALARM to exit sometimes, + * but to popen, system, fork carry on parent signal handler + * so we mask it ourself. + */ + sigset_t s; + sigaddset(&s, SIGALRM); + sigprocmask(SIG_UNBLOCK, &s, NULL); + set_signal(SIGALRM, doexit); + if (hints.ai_family != AF_INET6) create_socket(&sock4, AF_INET, hints.ai_socktype, IPPROTO_ICMP, hints.ai_family == AF_INET); -- 2.17.1