Firstly, you can use sigprocmask with an empty set pointer.
int sigprocmask(int how, const sigset_t *set, sigset_t *oldset);
a. how can be set to:
SIG_UNBLOCK
(the signal in set are removed from the current set of blocked signals. It is legal to attempt to unblock signal which is not blocked)
b. set
can be set to NULL
(as you don't want to change the blocked signals)
c. If oldset
is not NULL
, the previous value of the signal mask is stored in oldset. Ergo, you get the blocked signals in the location whose address is stored in oldset.
Secondly, for knowing if you are in a signal handling routine, when you write the signal handler definition, you can accept int signum as a parameter, as in:
void mySignalHandler(int signum);
If you want to know so that you can block some other signals at that point of time, you could just have a blocking function at the start & unblocking function at the end (using sigprocmask()
). You could even set said signals to SIG_IGN
status to ignore them while handling the current signal (using signal()
).
Lastly, please read the man pages!
Edit:
Since the author says he does read them, I recommend using the apropos command to find such hard-to-find functions. For example,
$ apropos "blocked signals"
gives you around 5 hits, 1 of which is sigprocmask
Cheers!