]> Savannah Git Hosting - gnulib.git/commitdiff
fatal-signal: Pass the signal number to the action.
authorBruno Haible <bruno@clisp.org>
Sat, 16 Mar 2019 21:56:21 +0000 (22:56 +0100)
committerBruno Haible <bruno@clisp.org>
Sat, 16 Mar 2019 21:56:21 +0000 (22:56 +0100)
* lib/fatal-signal.h (at_fatal_signal): Change the signature.
* lib/fatal-signal.c (action_t): Take the signal number as parameter.
(fatal_signal_handler): Pass the signal number to the action.
* lib/clean-temp.c (cleanup_action): Renamed from cleanup. Take the
signal number as parameter.
(create_temp_dir): Update.
* lib/wait-process.c (cleanup_slaves_action): New function.
(register_slave_subprocess): Update at_fatal_signal invocation.
* NEWS: Mention the change.

ChangeLog
NEWS
lib/clean-temp.c
lib/fatal-signal.c
lib/fatal-signal.h
lib/wait-process.c

index 519e85326b8fd8391571a90b0e3e0b2c1391b1ff..ee12ff17d89f1ebf74d36cdf18beef0f78bd2dcf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,16 @@
+2019-03-16  Bruno Haible  <bruno@clisp.org>
+
+       fatal-signal: Pass the signal number to the action.
+       * lib/fatal-signal.h (at_fatal_signal): Change the signature.
+       * lib/fatal-signal.c (action_t): Take the signal number as parameter.
+       (fatal_signal_handler): Pass the signal number to the action.
+       * lib/clean-temp.c (cleanup_action): Renamed from cleanup. Take the
+       signal number as parameter.
+       (create_temp_dir): Update.
+       * lib/wait-process.c (cleanup_slaves_action): New function.
+       (register_slave_subprocess): Update at_fatal_signal invocation.
+       * NEWS: Mention the change.
+
 2019-03-16  Bruno Haible  <bruno@clisp.org>
 
        fatal-signal: Add function that lists the fatal signals.
diff --git a/NEWS b/NEWS
index 612778495438253518e034ff978d269a7fa6b9a7..77b9f24a797607ae0168da406809b35c13463909 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,9 @@ Important general notes
 
 Date        Modules         Changes
 
+2019-03-16  fatal-signal    The function that you pass to at_fatal_signal now
+                            takes the signal as argument.
+
 2019-02-14  gnulib-tool     If you use multiple --local-dir options at once:
                             The first one now has the highest priority, not the
                             last one.
index c8d9bb7c972bbfc59be7cabae06c96a49cbcba4a..0cb4a7e406c0b30944860f192b4b7bda861d6ac9 100644 (file)
@@ -181,7 +181,7 @@ string_hash (const void *x)
 
 /* The signal handler.  It gets called asynchronously.  */
 static void
-cleanup ()
+cleanup_action (int sig _GL_UNUSED)
 {
   size_t i;
 
@@ -279,7 +279,7 @@ create_temp_dir (const char *prefix, const char *parentdir,
 
           if (old_allocated == 0)
             /* First use of this facility.  Register the cleanup handler.  */
-            at_fatal_signal (&cleanup);
+            at_fatal_signal (&cleanup_action);
           else
             {
               /* Don't use memcpy() here, because memcpy takes non-volatile
index 3bf43b087bd54cbce55d53f1fceee3ad82834c60..7f12f12c164a94b12f7b0aad0cd20e56915f76d2 100644 (file)
@@ -107,7 +107,7 @@ init_fatal_signals (void)
 /* ========================================================================= */
 
 
-typedef void (*action_t) (void);
+typedef void (*action_t) (int sig);
 
 /* Type of an entry in the actions array.
    The 'action' field is accessed from within the fatal_signal_handler(),
@@ -162,7 +162,7 @@ fatal_signal_handler (int sig)
       actions_count = n;
       action = actions[n].action;
       /* Execute the action.  */
-      action ();
+      action (sig);
     }
 
   /* Now execute the signal's default action.
index 22680e7ca425581ffa5480f3ac3d769a9d4a5693..c7d8e35d62cf8263cc57ba5c70a6c259e3d48c85 100644 (file)
@@ -51,7 +51,7 @@ extern "C" {
    The cleanup function is executed asynchronously.  It is unspecified
    whether during its execution the catchable fatal signals are blocked
    or not.  */
-extern void at_fatal_signal (void (*function) (void));
+extern void at_fatal_signal (void (*function) (int sig));
 
 
 /* Sometimes it is necessary to block the usually fatal signals while the
index 84c0e86b1f50535bac9950b318264d3c37aca16d..b51e2447a09a2266f37cc07d996a9b44d2427064 100644 (file)
@@ -102,6 +102,14 @@ cleanup_slaves (void)
     }
 }
 
+/* The cleanup action, taking a signal argument.
+   It gets called asynchronously.  */
+static void
+cleanup_slaves_action (int sig _GL_UNUSED)
+{
+  cleanup_slaves ();
+}
+
 /* Register a subprocess as being a slave process.  This means that the
    subprocess will be terminated when its creator receives a catchable fatal
    signal or exits normally.  Registration ends when wait_subprocess()
@@ -113,7 +121,7 @@ register_slave_subprocess (pid_t child)
   if (!cleanup_slaves_registered)
     {
       atexit (cleanup_slaves);
-      at_fatal_signal (cleanup_slaves);
+      at_fatal_signal (cleanup_slaves_action);
       cleanup_slaves_registered = true;
     }