linux-sysprog · intermediate · ~15 min

Was the child signalled?

Distinguish a signalled death from a normal exit.

Challenge

Emulate WIFSIGNALED: implement int was_signaled(int wstatus) returning 1 if the low 7 bits of wstatus are a real signal number (non-zero and not 0x7f, which means 'stopped'), else 0.

Starter code

int was_signaled(int wstatus) {
    /* TODO */
    return 0;
}

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