linux-sysprog · intermediate · ~15 min

Raise a signal to yourself

Deliver a signal synchronously with raise().

Challenge

Install a handler for SIGUSR1 that sets a flag, then raise(SIGUSR1). Implement int raise_and_flag(void) returning 1 if the handler ran.

Starter code

#include <signal.h>

int raise_and_flag(void) {
    /* TODO: install handler, raise(SIGUSR1), return the flag */
    return 0;
}

Solve this exercise in the browser editor — compile and run against the test harness, no setup required.