[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
fatal-signal: Add function that lists the fatal signals
From: |
Bruno Haible |
Subject: |
fatal-signal: Add function that lists the fatal signals |
Date: |
Sat, 16 Mar 2019 17:56:09 +0100 |
User-agent: |
KMail/5.1.3 (Linux/4.4.0-141-generic; KDE/5.18.0; x86_64; ; ) |
Some users of the 'fatal-signal' module want to block / unblock
not only the fatal signals, but also some other signals. Of course
a single sigaction() call is preferred to multiple ones. For this use-case,
it makes sense to add an accessor for the list of signals.
This accessor returns a list of signals, not a sigset_t, because it is not
clear to me, reading POSIX, whether cloning a sigset_t by simple assignment
is allowed. (Maybe POSIX allows a sigset_t to contain embedded pointers?)
Also, iterating through a list of 5 or 6 elements is probably more efficient
than iterating through a bitmap of 256 or 1024 bits.
2019-03-16 Bruno Haible <address@hidden>
fatal-signal: Add function that lists the fatal signals.
* lib/fatal-signal.h (get_fatal_signals): New declaration.
* lib/fatal-signal.c (get_fatal_signals): New function.
diff --git a/lib/fatal-signal.h b/lib/fatal-signal.h
index a2e60d3..22680e7 100644
--- a/lib/fatal-signal.h
+++ b/lib/fatal-signal.h
@@ -71,6 +71,12 @@ extern void block_fatal_signals (void);
extern void unblock_fatal_signals (void);
+/* Return the list of signals that block_fatal_signals/unblock_fatal_signals
+ would block or unblock.
+ Fills signals[0..count-1] and returns count. */
+extern unsigned int get_fatal_signals (int signals[64]);
+
+
#ifdef __cplusplus
}
#endif
diff --git a/lib/fatal-signal.c b/lib/fatal-signal.c
index 1fe31d1..3bf43b0 100644
--- a/lib/fatal-signal.c
+++ b/lib/fatal-signal.c
@@ -284,3 +284,20 @@ unblock_fatal_signals (void)
init_fatal_signal_set ();
sigprocmask (SIG_UNBLOCK, &fatal_signal_set, NULL);
}
+
+
+unsigned int
+get_fatal_signals (int signals[64])
+{
+ init_fatal_signal_set ();
+
+ {
+ int *p = signals;
+ size_t i;
+
+ for (i = 0; i < num_fatal_signals; i++)
+ if (fatal_signals[i] >= 0)
+ *p++ = fatal_signals[i];
+ return p - signals;
+ }
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- fatal-signal: Add function that lists the fatal signals,
Bruno Haible <=