linux-sysprog · intermediate · ~15 min

Does the handler get siginfo?

Detect the SA_SIGINFO flag.

Challenge

The SA_SIGINFO flag selects the three-argument sa_sigaction handler, which receives signal details and context instead of just the signal number. Test for it.

Task

Implement int gets_siginfo(int flags) that returns 1 if the SA_SIGINFO bit is set in flags, else 0.

Input

  • flags: an sa_flags value (bitmask).

Output

1 if SA_SIGINFO is set, else 0.

Example

gets_siginfo(SA_SIGINFO)   ->   1
gets_siginfo(SA_RESTART)   ->   0

Input format

flags: an sa_flags bitmask.

Output format

1 if the SA_SIGINFO bit is set, else 0.

Starter code

#include <signal.h>

int gets_siginfo(int flags) {
    /* TODO */
    return 0;
}

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