linux-sysprog · intermediate · ~15 min
Test a flag bit in the sigaction flags word.
sigaction's sa_flags word controls handler behaviour; the SA_RESTART bit makes interrupted slow syscalls resume instead of failing with EINTR. Test for it.
Implement int restarts_syscalls(int flags) that returns 1 if the SA_RESTART bit is set in flags, else 0.
flags: an sa_flags value (bitmask).1 if SA_RESTART is set, else 0.
restarts_syscalls(SA_RESTART) -> 1
restarts_syscalls(0) -> 0
flags: an sa_flags bitmask.
1 if the SA_RESTART bit is set, else 0.
#include <signal.h>
int restarts_syscalls(int flags) {
/* TODO */
return 0;
}
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.