~/ learn/ comp-325/ cards/ The interface the book never shows
1 of 10

The four lines that install a reliable handler

The four lines that install a reliable handler

Answer

struct sigaction sa; sa.sa_handler = on_int; sigemptyset(&sa.sa_mask); sa.sa_flags = SA_RESTART; if (sigaction(SIGINT, &sa, NULL) == -1) _exit(1);

Memorise this shape — it is the body of the A3 Q3 answer. sa_handler is the disposition, sigemptyset clears the extra block set (never skip it), SA_RESTART resumes an interrupted slow call, and sigaction returns -1 on failure.

POSIX.1-2024 (IEEE Std 1003.1-2024) — sigaction(), <signal.h>, and the async-signal-safe function list; sigaction(2)

space flip · ← → navigate · esc to exit
NORMAL ~/memra/library/318c561c-5caf-4e3f-be99-dbe7dd3e6c12/flashcard utf-8 LF