linux-sysprog · beginner · ~15 min
Group the process-ending signals.
Some signals exist to end a process (Ctrl-C, kill, etc.). Classify a signal number as one of those.
Implement int is_termination_signal(int sig) that returns 1 if sig is one of SIGINT, SIGTERM, SIGKILL, or SIGQUIT, else 0.
sig: a signal number (compare against the signal.h constants, not raw numbers).1 for the four termination signals above, else 0.
is_termination_signal(SIGTERM) -> 1
is_termination_signal(SIGINT) -> 1
is_termination_signal(SIGCONT) -> 0
sig: a signal number from <signal.h>.
1 for SIGINT/SIGTERM/SIGKILL/SIGQUIT, else 0.
Match by the signal.h constants, not hardcoded numbers.
#include <signal.h>
int is_termination_signal(int sig) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.