From fc03f7cfa017c2997fabcac0a70308f3da71d5f9 Mon Sep 17 00:00:00 2001 From: Gustavo Martin Morcuende Date: Wed, 16 Dec 2015 01:26:10 +0100 Subject: [PATCH] From sig handler just call safe functions. As long as you don't do what R.. user says in the comments below the answer you must use only safe functions. http://stackoverflow.com/questions/8833394/can-exit-fail-to-terminate-process/8833602#8833602 --- Daemon/javafork.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Daemon/javafork.c b/Daemon/javafork.c index 8ecb5e8..320d6f5 100644 --- a/Daemon/javafork.c +++ b/Daemon/javafork.c @@ -907,7 +907,15 @@ void sigint_handler(int sig) */ if (sigaction(SIGINT, &sigintAction, NULL) < 0) { syslog (LOG_ERR, "SIGINT restore signal handler failed: %m"); - exit (EXIT_FAILURE); + /* man 7 signal + * Async-signal-safe functions + * A signal handler function must be very careful, since processing elsewhere may be interrupted at some arbitrary + * point in the execution of the program. POSIX has the concept of "safe function". If a signal interrupts the + * execution of an unsafe function, and handler calls an unsafe function, then the behavior of the program is undefined. + * + * From sig handler I MAY USE JUST _exit + */ + _exit (EXIT_FAILURE); } kill(getpid(), SIGINT); } -- 2.1.4