From sig handler just call safe functions. master origin/HEAD origin/master
authorGustavo Martin Morcuende <gu.martinm@gmail.com>
Wed, 16 Dec 2015 00:26:10 +0000 (01:26 +0100)
committerGustavo Martin Morcuende <gu.martinm@gmail.com>
Wed, 16 Dec 2015 00:26:10 +0000 (01:26 +0100)
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

index 8ecb5e8..320d6f5 100644 (file)
@@ -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);
 }