linux-sysprog · advanced · ~15 min
Signal handler basics and the safe types/operations available inside one.
Implement int count_sigusr1(int times) that installs a SIGUSR1 handler, raises SIGUSR1 times times (via raise(SIGUSR1)), then returns the handler invocation count. The counter must be volatile sig_atomic_t.
#include <signal.h>
int count_sigusr1(int times) {
/* TODO */
return -1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.