Hi,
 The attached patch replaces the call of exit() with _exit() in signal
handlers. exit() is not one of the functions that can be cleanly called
from a signal handler (see signal(7))

regards,
Nikos

From ef0bdd39fb814ed2af7170cce19dae6a57213677 Mon Sep 17 00:00:00 2001
From: Nikos Mavrogiannopoulos <[email protected]>
Date: Fri, 13 May 2016 11:20:43 +0200
Subject: [PATCH] intdiv0, memmem, nocrash, strcasestr, strstr: avoid call of
 exit() on signal handlers

This addresses issue with tests not being terminated.
---
 m4/intdiv0.m4    | 2 +-
 m4/memmem.m4     | 2 +-
 m4/nocrash.m4    | 3 ++-
 m4/strcasestr.m4 | 2 +-
 m4/strstr.m4     | 2 +-
 5 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/m4/intdiv0.m4 b/m4/intdiv0.m4
index a442fd5..744b99e 100644
--- a/m4/intdiv0.m4
+++ b/m4/intdiv0.m4
@@ -38,7 +38,7 @@ static void
 sigfpe_handler (int sig)
 {
   /* Exit with code 0 if SIGFPE, with code 1 if any other signal.  */
-  exit (sig != SIGFPE);
+  _exit (sig != SIGFPE);
 }
 
 int x = 1;
diff --git a/m4/memmem.m4 b/m4/memmem.m4
index 624e9b8..981ede7 100644
--- a/m4/memmem.m4
+++ b/m4/memmem.m4
@@ -93,7 +93,7 @@ AC_DEFUN([gl_FUNC_MEMMEM],
 #include <string.h> /* for memmem */
 #include <stdlib.h> /* for malloc */
 #include <unistd.h> /* for alarm */
-static void quit (int sig) { exit (sig + 128); }
+static void quit (int sig) { _exit (sig + 128); }
 ]], [[
     int result = 0;
     size_t m = 1000000;
diff --git a/m4/nocrash.m4 b/m4/nocrash.m4
index ecc55c6..d8dd8f1 100644
--- a/m4/nocrash.m4
+++ b/m4/nocrash.m4
@@ -110,11 +110,12 @@ nocrash_init (void)
 #else
 /* Avoid a crash on POSIX systems.  */
 #include <signal.h>
+#include <unistd.h>
 /* A POSIX signal handler.  */
 static void
 exception_handler (int sig)
 {
-  exit (1);
+  _exit (1);
 }
 static void
 nocrash_init (void)
diff --git a/m4/strcasestr.m4 b/m4/strcasestr.m4
index 7c44cdd..bed5771 100644
--- a/m4/strcasestr.m4
+++ b/m4/strcasestr.m4
@@ -80,7 +80,7 @@ AC_DEFUN([gl_FUNC_STRCASESTR],
 #include <string.h> /* for strcasestr */
 #include <stdlib.h> /* for malloc */
 #include <unistd.h> /* for alarm */
-static void quit (int sig) { exit (sig + 128); }
+static void quit (int sig) { _exit (sig + 128); }
 ]], [[
     int result = 0;
     size_t m = 1000000;
diff --git a/m4/strstr.m4 b/m4/strstr.m4
index b2a3646..77db2a4 100644
--- a/m4/strstr.m4
+++ b/m4/strstr.m4
@@ -71,7 +71,7 @@ AC_DEFUN([gl_FUNC_STRSTR],
 #include <string.h> /* for strstr */
 #include <stdlib.h> /* for malloc */
 #include <unistd.h> /* for alarm */
-static void quit (int sig) { exit (sig + 128); }
+static void quit (int sig) { _exit (sig + 128); }
 ]], [[
     int result = 0;
     size_t m = 1000000;
-- 
2.5.5

Reply via email to