# HG changeset patch # User Bruno Haible # Date 1552773381 -3600 # Node ID 3ac749aa0041f27879b1d3fa7305e959cc2ccd7b # Parent b1386ce84ff56e30965dac11a923a4cbba70e2ce 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. diff -r b1386ce84ff5 -r 3ac749aa0041 ChangeLog --- a/ChangeLog Sat Mar 16 17:48:06 2019 +0100 +++ b/ChangeLog Sat Mar 16 22:56:21 2019 +0100 @@ -1,3 +1,16 @@ +2019-03-16 Bruno Haible + + 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 fatal-signal: Add function that lists the fatal signals. diff -r b1386ce84ff5 -r 3ac749aa0041 NEWS --- a/NEWS Sat Mar 16 17:48:06 2019 +0100 +++ b/NEWS Sat Mar 16 22:56:21 2019 +0100 @@ -3,6 +3,9 @@ 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. diff -r b1386ce84ff5 -r 3ac749aa0041 lib/clean-temp.c --- a/lib/clean-temp.c Sat Mar 16 17:48:06 2019 +0100 +++ b/lib/clean-temp.c Sat Mar 16 22:56:21 2019 +0100 @@ -181,7 +181,7 @@ /* The signal handler. It gets called asynchronously. */ static void -cleanup () +cleanup_action (int sig _GL_UNUSED) { size_t i; @@ -279,7 +279,7 @@ 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 diff -r b1386ce84ff5 -r 3ac749aa0041 lib/fatal-signal.c --- a/lib/fatal-signal.c Sat Mar 16 17:48:06 2019 +0100 +++ b/lib/fatal-signal.c Sat Mar 16 22:56:21 2019 +0100 @@ -107,7 +107,7 @@ /* ========================================================================= */ -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 @@ actions_count = n; action = actions[n].action; /* Execute the action. */ - action (); + action (sig); } /* Now execute the signal's default action. diff -r b1386ce84ff5 -r 3ac749aa0041 lib/fatal-signal.h --- a/lib/fatal-signal.h Sat Mar 16 17:48:06 2019 +0100 +++ b/lib/fatal-signal.h Sat Mar 16 22:56:21 2019 +0100 @@ -51,7 +51,7 @@ 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 diff -r b1386ce84ff5 -r 3ac749aa0041 lib/wait-process.c --- a/lib/wait-process.c Sat Mar 16 17:48:06 2019 +0100 +++ b/lib/wait-process.c Sat Mar 16 22:56:21 2019 +0100 @@ -102,6 +102,14 @@ } } +/* 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 @@ if (!cleanup_slaves_registered) { atexit (cleanup_slaves); - at_fatal_signal (cleanup_slaves); + at_fatal_signal (cleanup_slaves_action); cleanup_slaves_registered = true; }