linux-sysprog · intermediate · ~15 min
Enforce the 'only set a flag' handler discipline.
A handler op trace uses 's' (set a volatile sig_atomic_t flag — safe) and 'p' (call printf — unsafe). Implement int handler_is_safe(const char *ops) returning 1 only if every op is 's'.
int handler_is_safe(const char *ops) {
/* TODO */
return 1;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.