linux-sysprog · beginner · ~15 min

Force-quit on second Ctrl-C

Model the two-strike shutdown policy.

Challenge

Many programs exit only after a second Ctrl-C. Implement int should_force_exit(int sigint_count) returning 1 if sigint_count is 2 or more, else 0.

Starter code

int should_force_exit(int sigint_count) {
    /* TODO */
    return 0;
}

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