annotate lib/fatal-signal.c @ 40238:3ac749aa0041

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.
author Bruno Haible <bruno@clisp.org>
date Sat, 16 Mar 2019 22:56:21 +0100
parents b1386ce84ff5
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
1 /* Emergency actions in case of a fatal signal.
40057
b06060465f09 maint: Run 'make update-copyright'
Paul Eggert <eggert@cs.ucla.edu>
parents: 19484
diff changeset
2 Copyright (C) 2003-2004, 2006-2019 Free Software Foundation, Inc.
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
3 Written by Bruno Haible <bruno@clisp.org>, 2003.
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
4
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8783
diff changeset
5 This program is free software: you can redistribute it and/or modify
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
6 it under the terms of the GNU General Public License as published by
9309
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8783
diff changeset
7 the Free Software Foundation; either version 3 of the License, or
bbbbbf4cd1c5 Change copyright notice from GPLv2+ to GPLv3+.
Bruno Haible <bruno@clisp.org>
parents: 8783
diff changeset
8 (at your option) any later version.
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
9
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
10 This program is distributed in the hope that it will be useful,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
13 GNU General Public License for more details.
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
14
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
15 You should have received a copy of the GNU General Public License
19190
9759915b2aca all: prefer https: URLs
Paul Eggert <eggert@cs.ucla.edu>
parents: 18626
diff changeset
16 along with this program. If not, see <https://www.gnu.org/licenses/>. */
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
17
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
18
7304
1c4ed7637c24 Include <config.h> unconditionally.
Bruno Haible <bruno@clisp.org>
parents: 7014
diff changeset
19 #include <config.h>
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
20
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
21 /* Specification. */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
22 #include "fatal-signal.h"
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
23
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
24 #include <stdbool.h>
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
25 #include <stdlib.h>
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
26 #include <signal.h>
6751
1b0092424a44 Include <unistd.h> unconditionally.
Bruno Haible <bruno@clisp.org>
parents: 6259
diff changeset
27 #include <unistd.h>
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
28
10230
54813304edd2 Use sigaction module rather than signal().
Eric Blake <ebb9@byu.net>
parents: 10221
diff changeset
29 #include "sig-handler.h"
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
30 #include "xalloc.h"
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
31
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
32 #define SIZEOF(a) (sizeof(a) / sizeof(a[0]))
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
33
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
34 /* ========================================================================= */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
35
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
36
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
37 /* The list of fatal signals.
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
38 These are those signals whose default action is to terminate the process
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
39 without a core dump, except
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
40 SIGKILL - because it cannot be caught,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
41 SIGALRM SIGUSR1 SIGUSR2 SIGPOLL SIGIO SIGLOST - because applications
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
42 often use them for their own purpose,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
43 SIGPROF SIGVTALRM - because they are used for profiling,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
44 SIGSTKFLT - because it is more similar to SIGFPE, SIGSEGV, SIGBUS,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
45 SIGSYS - because it is more similar to SIGABRT, SIGSEGV,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
46 SIGPWR - because it of too special use,
4786
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
47 SIGRTMIN...SIGRTMAX - because they are reserved for application use.
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
48 plus
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
49 SIGXCPU, SIGXFSZ - because they are quite similar to SIGTERM. */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
50
5536
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
51 static int fatal_signals[] =
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
52 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
53 /* ISO C 99 signals. */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
54 #ifdef SIGINT
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
55 SIGINT,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
56 #endif
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
57 #ifdef SIGTERM
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
58 SIGTERM,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
59 #endif
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
60 /* POSIX:2001 signals. */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
61 #ifdef SIGHUP
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
62 SIGHUP,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
63 #endif
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
64 #ifdef SIGPIPE
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
65 SIGPIPE,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
66 #endif
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
67 /* BSD signals. */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
68 #ifdef SIGXCPU
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
69 SIGXCPU,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
70 #endif
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
71 #ifdef SIGXFSZ
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
72 SIGXFSZ,
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
73 #endif
16242
59c686e5b2df Talk about "native Windows API", not "Woe32".
Bruno Haible <bruno@clisp.org>
parents: 16201
diff changeset
74 /* Native Windows signals. */
7404
71b958155bb9 Handle the Woe32 SIGBREAK too.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
75 #ifdef SIGBREAK
71b958155bb9 Handle the Woe32 SIGBREAK too.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
76 SIGBREAK,
71b958155bb9 Handle the Woe32 SIGBREAK too.
Bruno Haible <bruno@clisp.org>
parents: 7304
diff changeset
77 #endif
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
78 0
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
79 };
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
80
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
81 #define num_fatal_signals (SIZEOF (fatal_signals) - 1)
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
82
5536
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
83 /* Eliminate signals whose signal handler is SIG_IGN. */
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
84
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
85 static void
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
86 init_fatal_signals (void)
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
87 {
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
88 static bool fatal_signals_initialized = false;
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
89 if (!fatal_signals_initialized)
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
90 {
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
91 size_t i;
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
92
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
93 for (i = 0; i < num_fatal_signals; i++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
94 {
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
95 struct sigaction action;
5536
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
96
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
97 if (sigaction (fatal_signals[i], NULL, &action) >= 0
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
98 && get_handler (&action) == SIG_IGN)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
99 fatal_signals[i] = -1;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
100 }
5536
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
101
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
102 fatal_signals_initialized = true;
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
103 }
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
104 }
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
105
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
106
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
107 /* ========================================================================= */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
108
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
109
40238
3ac749aa0041 fatal-signal: Pass the signal number to the action.
Bruno Haible <bruno@clisp.org>
parents: 40237
diff changeset
110 typedef void (*action_t) (int sig);
4786
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
111
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
112 /* Type of an entry in the actions array.
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
113 The 'action' field is accessed from within the fatal_signal_handler(),
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
114 therefore we mark it as 'volatile'. */
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
115 typedef struct
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
116 {
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
117 volatile action_t action;
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
118 }
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
119 actions_entry_t;
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
120
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
121 /* The registered cleanup actions. */
4786
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
122 static actions_entry_t static_actions[32];
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
123 static actions_entry_t * volatile actions = static_actions;
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
124 static sig_atomic_t volatile actions_count = 0;
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
125 static size_t actions_allocated = SIZEOF (static_actions);
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
126
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
127
10381
31614a69f913 Don't override previously installed signal handlers.
Bruno Haible <bruno@clisp.org>
parents: 10244
diff changeset
128 /* The saved signal handlers.
31614a69f913 Don't override previously installed signal handlers.
Bruno Haible <bruno@clisp.org>
parents: 10244
diff changeset
129 Size 32 would not be sufficient: On HP-UX, SIGXCPU = 33, SIGXFSZ = 34. */
31614a69f913 Don't override previously installed signal handlers.
Bruno Haible <bruno@clisp.org>
parents: 10244
diff changeset
130 static struct sigaction saved_sigactions[64];
31614a69f913 Don't override previously installed signal handlers.
Bruno Haible <bruno@clisp.org>
parents: 10244
diff changeset
131
31614a69f913 Don't override previously installed signal handlers.
Bruno Haible <bruno@clisp.org>
parents: 10244
diff changeset
132
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
133 /* Uninstall the handlers. */
17185
dd46d4e6beea dup, execute, fatal-signal, etc.: no 'static inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 16364
diff changeset
134 static void
16364
89227b989588 fatal-signal: use C prototypes (with explicit void).
Akim Demaille <demaille@gostai.com>
parents: 16242
diff changeset
135 uninstall_handlers (void)
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
136 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
137 size_t i;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
138
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
139 for (i = 0; i < num_fatal_signals; i++)
5536
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
140 if (fatal_signals[i] >= 0)
10381
31614a69f913 Don't override previously installed signal handlers.
Bruno Haible <bruno@clisp.org>
parents: 10244
diff changeset
141 {
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
142 int sig = fatal_signals[i];
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
143 if (saved_sigactions[sig].sa_handler == SIG_IGN)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
144 saved_sigactions[sig].sa_handler = SIG_DFL;
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
145 sigaction (sig, &saved_sigactions[sig], NULL);
10381
31614a69f913 Don't override previously installed signal handlers.
Bruno Haible <bruno@clisp.org>
parents: 10244
diff changeset
146 }
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
147 }
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
148
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
149
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
150 /* The signal handler. It gets called asynchronously. */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
151 static void
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
152 fatal_signal_handler (int sig)
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
153 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
154 for (;;)
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
155 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
156 /* Get the last registered cleanup action, in a reentrant way. */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
157 action_t action;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
158 size_t n = actions_count;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
159 if (n == 0)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
160 break;
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
161 n--;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
162 actions_count = n;
4786
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
163 action = actions[n].action;
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
164 /* Execute the action. */
40238
3ac749aa0041 fatal-signal: Pass the signal number to the action.
Bruno Haible <bruno@clisp.org>
parents: 40237
diff changeset
165 action (sig);
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
166 }
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
167
4786
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
168 /* Now execute the signal's default action.
10244
478a8cd21855 Reenter the fatal_signal_handler in case of nested signal.
Bruno Haible <bruno@clisp.org>
parents: 10230
diff changeset
169 If the signal being delivered was blocked, the re-raised signal would be
478a8cd21855 Reenter the fatal_signal_handler in case of nested signal.
Bruno Haible <bruno@clisp.org>
parents: 10230
diff changeset
170 delivered when this handler returns. But the way we install this handler,
478a8cd21855 Reenter the fatal_signal_handler in case of nested signal.
Bruno Haible <bruno@clisp.org>
parents: 10230
diff changeset
171 no signal is blocked, and the re-raised signal is delivered already
478a8cd21855 Reenter the fatal_signal_handler in case of nested signal.
Bruno Haible <bruno@clisp.org>
parents: 10230
diff changeset
172 during raise(). */
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
173 uninstall_handlers ();
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
174 raise (sig);
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
175 }
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
176
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
177
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
178 /* Install the handlers. */
17185
dd46d4e6beea dup, execute, fatal-signal, etc.: no 'static inline'
Paul Eggert <eggert@cs.ucla.edu>
parents: 16364
diff changeset
179 static void
16364
89227b989588 fatal-signal: use C prototypes (with explicit void).
Akim Demaille <demaille@gostai.com>
parents: 16242
diff changeset
180 install_handlers (void)
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
181 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
182 size_t i;
10230
54813304edd2 Use sigaction module rather than signal().
Eric Blake <ebb9@byu.net>
parents: 10221
diff changeset
183 struct sigaction action;
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
184
10230
54813304edd2 Use sigaction module rather than signal().
Eric Blake <ebb9@byu.net>
parents: 10221
diff changeset
185 action.sa_handler = &fatal_signal_handler;
10244
478a8cd21855 Reenter the fatal_signal_handler in case of nested signal.
Bruno Haible <bruno@clisp.org>
parents: 10230
diff changeset
186 /* If we get a fatal signal while executing fatal_signal_handler, enter
478a8cd21855 Reenter the fatal_signal_handler in case of nested signal.
Bruno Haible <bruno@clisp.org>
parents: 10230
diff changeset
187 fatal_signal_handler recursively, since it is reentrant. Hence no
478a8cd21855 Reenter the fatal_signal_handler in case of nested signal.
Bruno Haible <bruno@clisp.org>
parents: 10230
diff changeset
188 SA_RESETHAND. */
478a8cd21855 Reenter the fatal_signal_handler in case of nested signal.
Bruno Haible <bruno@clisp.org>
parents: 10230
diff changeset
189 action.sa_flags = SA_NODEFER;
10230
54813304edd2 Use sigaction module rather than signal().
Eric Blake <ebb9@byu.net>
parents: 10221
diff changeset
190 sigemptyset (&action.sa_mask);
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
191 for (i = 0; i < num_fatal_signals; i++)
5536
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
192 if (fatal_signals[i] >= 0)
10381
31614a69f913 Don't override previously installed signal handlers.
Bruno Haible <bruno@clisp.org>
parents: 10244
diff changeset
193 {
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
194 int sig = fatal_signals[i];
10381
31614a69f913 Don't override previously installed signal handlers.
Bruno Haible <bruno@clisp.org>
parents: 10244
diff changeset
195
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
196 if (!(sig < sizeof (saved_sigactions) / sizeof (saved_sigactions[0])))
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
197 abort ();
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
198 sigaction (sig, &action, &saved_sigactions[sig]);
10381
31614a69f913 Don't override previously installed signal handlers.
Bruno Haible <bruno@clisp.org>
parents: 10244
diff changeset
199 }
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
200 }
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
201
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
202
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
203 /* Register a cleanup function to be executed when a catchable fatal signal
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
204 occurs. */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
205 void
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
206 at_fatal_signal (action_t action)
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
207 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
208 static bool cleanup_initialized = false;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
209 if (!cleanup_initialized)
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
210 {
5536
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
211 init_fatal_signals ();
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
212 install_handlers ();
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
213 cleanup_initialized = true;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
214 }
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
215
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
216 if (actions_count == actions_allocated)
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
217 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
218 /* Extend the actions array. Note that we cannot use xrealloc(),
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
219 because then the cleanup() function could access an already
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
220 deallocated array. */
4786
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
221 actions_entry_t *old_actions = actions;
7014
43bb3848f1c7 Merge from gettext 0.15: Be more careful to use 'volatile'.
Bruno Haible <bruno@clisp.org>
parents: 6751
diff changeset
222 size_t old_actions_allocated = actions_allocated;
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
223 size_t new_actions_allocated = 2 * actions_allocated;
4786
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
224 actions_entry_t *new_actions =
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
225 XNMALLOC (new_actions_allocated, actions_entry_t);
7014
43bb3848f1c7 Merge from gettext 0.15: Be more careful to use 'volatile'.
Bruno Haible <bruno@clisp.org>
parents: 6751
diff changeset
226 size_t k;
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
227
7014
43bb3848f1c7 Merge from gettext 0.15: Be more careful to use 'volatile'.
Bruno Haible <bruno@clisp.org>
parents: 6751
diff changeset
228 /* Don't use memcpy() here, because memcpy takes non-volatile arguments
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
229 and is therefore not guaranteed to complete all memory stores before
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
230 the next statement. */
7014
43bb3848f1c7 Merge from gettext 0.15: Be more careful to use 'volatile'.
Bruno Haible <bruno@clisp.org>
parents: 6751
diff changeset
231 for (k = 0; k < old_actions_allocated; k++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
232 new_actions[k] = old_actions[k];
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
233 actions = new_actions;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
234 actions_allocated = new_actions_allocated;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
235 /* Now we can free the old actions array. */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
236 if (old_actions != static_actions)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
237 free (old_actions);
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
238 }
4786
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
239 /* The two uses of 'volatile' in the types above (and ISO C 99 section
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
240 5.1.2.3.(5)) ensure that we increment the actions_count only after
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
241 the new action has been written to the memory location
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
242 actions[actions_count]. */
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
243 actions[actions_count].action = action;
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
244 actions_count++;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
245 }
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
246
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
247
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
248 /* ========================================================================= */
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
249
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
250
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
251 static sigset_t fatal_signal_set;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
252
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
253 static void
16364
89227b989588 fatal-signal: use C prototypes (with explicit void).
Akim Demaille <demaille@gostai.com>
parents: 16242
diff changeset
254 init_fatal_signal_set (void)
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
255 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
256 static bool fatal_signal_set_initialized = false;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
257 if (!fatal_signal_set_initialized)
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
258 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
259 size_t i;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
260
5536
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
261 init_fatal_signals ();
f64f1da7e350 Signals whose handler is set to SIG_IGN are not fatal.
Bruno Haible <bruno@clisp.org>
parents: 4786
diff changeset
262
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
263 sigemptyset (&fatal_signal_set);
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
264 for (i = 0; i < num_fatal_signals; i++)
12421
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
265 if (fatal_signals[i] >= 0)
e8d2c6fc33ad Use spaces for indentation, not tabs.
Bruno Haible <bruno@clisp.org>
parents: 10383
diff changeset
266 sigaddset (&fatal_signal_set, fatal_signals[i]);
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
267
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
268 fatal_signal_set_initialized = true;
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
269 }
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
270 }
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
271
4786
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
272 /* Temporarily delay the catchable fatal signals. */
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
273 void
16364
89227b989588 fatal-signal: use C prototypes (with explicit void).
Akim Demaille <demaille@gostai.com>
parents: 16242
diff changeset
274 block_fatal_signals (void)
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
275 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
276 init_fatal_signal_set ();
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
277 sigprocmask (SIG_BLOCK, &fatal_signal_set, NULL);
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
278 }
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
279
4786
83d8d561903a Improved 'fatal-signal' module.
Bruno Haible <bruno@clisp.org>
parents: 4770
diff changeset
280 /* Stop delaying the catchable fatal signals. */
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
281 void
16364
89227b989588 fatal-signal: use C prototypes (with explicit void).
Akim Demaille <demaille@gostai.com>
parents: 16242
diff changeset
282 unblock_fatal_signals (void)
4770
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
283 {
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
284 init_fatal_signal_set ();
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
285 sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL);
6708dc21dacc New module 'fatal-signal'.
Bruno Haible <bruno@clisp.org>
parents:
diff changeset
286 }
40237
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
287
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
288
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
289 unsigned int
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
290 get_fatal_signals (int signals[64])
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
291 {
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
292 init_fatal_signal_set ();
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
293
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
294 {
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
295 int *p = signals;
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
296 size_t i;
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
297
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
298 for (i = 0; i < num_fatal_signals; i++)
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
299 if (fatal_signals[i] >= 0)
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
300 *p++ = fatal_signals[i];
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
301 return p - signals;
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
302 }
b1386ce84ff5 fatal-signal: Add function that lists the fatal signals.
Bruno Haible <bruno@clisp.org>
parents: 40057
diff changeset
303 }