linux-sysprog · intermediate · ~15 min

Count raised signals

Observe repeated synchronous delivery.

Challenge

Install a SIGUSR1 handler that increments a counter, raise it twice, and implement int raise_twice(void) returning the counter (2).

Starter code

#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.