linux-sysprog · intermediate · ~15 min
Catch SIGINT to shut down gracefully.
Implement int catch_sigint(void) that installs a SIGINT handler (setting a flag), raises SIGINT, and returns the flag (1) — so Ctrl-C is handled instead of terminating the process.
#include <signal.h>
int catch_sigint(void) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.