linux-sysprog · beginner · ~15 min
Know the two uncatchable signals.
Almost every signal can be caught by a handler — except two that the kernel reserves so a process can always be killed or paused. Identify whether a signal is catchable.
Implement int is_catchable(int sig) that returns 1 if sig can be caught or ignored, else 0.
sig: a signal number (compare against the <signal.h> constants).0 for SIGKILL and SIGSTOP; 1 for any other signal.
is_catchable(SIGINT) -> 1
is_catchable(SIGKILL) -> 0
is_catchable(SIGSTOP) -> 0
sig: a signal number from <signal.h>.
0 for SIGKILL/SIGSTOP, else 1.
Match by the signal.h constants.
#include <signal.h>
int is_catchable(int sig) {
/* TODO */
return 1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.