linux-sysprog · intermediate · ~15 min
Recall which calls are legal inside a signal handler.
Only async-signal-safe functions may be called from a handler. Implement int is_async_signal_safe(const char *fn) returning 1 for "write", "_exit", "signal", "kill", "read", and 0 for "printf", "malloc", "free".
#include <string.h>
int is_async_signal_safe(const char *fn) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.