linux-sysprog · intermediate · ~15 min
Use kill() with your own PID.
Implement int kill_self(void) that installs a SIGUSR1 handler (setting a flag) and uses kill(getpid(), SIGUSR1) to send itself the signal, returning the flag.
#include <signal.h>
#include <unistd.h>
int kill_self(void) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.