A simple way to find out whether a process signal is masked or shelved in C
- 2020-04-02 03:21:23
- OfStack
C language sigprocmask() function: query or set the signal mask
The header file:
#include <signal.h>
Definition function:
int sigprocmask(int how, const sigset_t *set, sigset_t * oldset);
Function description: sigprocmask() can be used to change the current signal mask, its operation depends on the parameter how:
1. The new signal mask of SIG_BLOCK is composed of the current signal mask and the signal mask specified by the parameter set
2. SIG_UNBLOCK removes the current signal mask from the signal mask specified by the parameter set
SIG_SETMASK sets the current signal mask to the signal mask specified by the parameter set. If the parameter oldset is not a NULL pointer, the current signal mask will be returned by this pointer.
Return value: 0 on success or -1 on error.
Error code:
1. EFAULT parameter set, oldset pointer address cannot be accessed.
2, EINTR this call is interrupted.
C language sigpending() function: query the pending signal
The header file:
#include <signal.h>
Definition function:
int sigpending(sigset_t *set);
Function description: sigpending() will return the pending signal set by the parameter set pointer.
Error code:
1. The address of the EFAULT parameter set pointer cannot be accessed
2, EINTR this call is interrupted.