changeset 10244:478a8cd21855

Reenter the fatal_signal_handler in case of nested signal.
author Bruno Haible <bruno@clisp.org>
date Mon, 23 Jun 2008 22:33:28 +0200
parents f3834f370cbd
children 18a5b4f796a2
files ChangeLog lib/fatal-signal.c
diffstat 2 files changed, 13 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Mon Jun 23 22:30:46 2008 +0200
+++ b/ChangeLog	Mon Jun 23 22:33:28 2008 +0200
@@ -1,3 +1,8 @@
+2008-06-23  Bruno Haible  <bruno@clisp.org>
+
+	* lib/fatal-signal.c (fatal_signal_handler): Update comment.
+	(install_handlers): Don't set the SA_RESETHAND flag.
+
 2008-06-23  Bruno Haible  <bruno@clisp.org>
 
 	* m4/sigaction.m4: Comment fixes.
--- a/lib/fatal-signal.c	Mon Jun 23 22:30:46 2008 +0200
+++ b/lib/fatal-signal.c	Mon Jun 23 22:33:28 2008 +0200
@@ -160,9 +160,10 @@
     }
 
   /* Now execute the signal's default action.
-     If any cleanup action blocks the signal that triggered the cleanup, the
-     re-raised signal is delivered when this handler returns; otherwise it
-     is delivered already during raise().  */
+     If the signal being delivered was blocked, the re-raised signal would be
+     delivered when this handler returns.  But the way we install this handler,
+     no signal is blocked, and the re-raised signal is delivered already
+     during raise().  */
   uninstall_handlers ();
   raise (sig);
 }
@@ -176,9 +177,10 @@
   struct sigaction action;
 
   action.sa_handler = &fatal_signal_handler;
-  /* One-shot handling - if we fault while handling a fault, the
-     cleanup actions are intentionally cut short.  */
-  action.sa_flags = SA_NODEFER | SA_RESETHAND;
+  /* If we get a fatal signal while executing fatal_signal_handler, enter
+     fatal_signal_handler recursively, since it is reentrant.  Hence no
+     SA_RESETHAND.  */
+  action.sa_flags = SA_NODEFER;
   sigemptyset (&action.sa_mask);
   for (i = 0; i < num_fatal_signals; i++)
     if (fatal_signals[i] >= 0)