linux-sysprog · intermediate · ~15 min
Observe repeated synchronous delivery.
Each synchronous raise() runs the handler exactly once, so raising a signal twice increments a counter to 2. Demonstrate that.
Implement int raise_twice(void) that installs a SIGUSR1 handler which increments a counter, calls raise(SIGUSR1) twice, and returns the counter.
None.
2 — the counter after two synchronous deliveries.
raise_twice() -> 2
static volatile sig_atomic_t counter.None.
2 — the handler count after raising SIGUSR1 twice.
Use a sig_atomic_t counter; install the handler first.
#include <signal.h>
int raise_twice(void) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.