Using signal() or, preferably, sigaction(), we can choose to ignore or explicitly handle most of the POSIX signals. For example, in order to ignore SIGCHLD we could do the following:
struct sigaction sa_chld = { .sa_handler = SIG_IGN };
sigaction(SIGCHLD, &sa_chld, NULL);
Is there also a way to figure out if a given signal is being ignored and/or caught by the program?
Ideally, I'd like to distinguish if a signal...
- is being handled as per the default actions
- is being ignored explicitly
- is being caught explicitly