Questions: Signal Handling and Delivery

5 questions to test your understanding

Score: 0 / 5
Question 1 Multiple Choice

A process is in the middle of updating a doubly-linked list when SIGUSR1 arrives. The signal handler also modifies the same list. What is the most likely outcome?

ANo problem — signal handlers run in a separate thread and cannot interfere with the main process
BA race condition or data corruption, because the signal interrupts execution at an arbitrary instruction
CThe signal is automatically queued until the linked-list update completes safely
DThe handler waits for the main code to finish the current operation before executing
Question 2 Multiple Choice

A signal handler needs to trigger complex processing: writing a log file and restarting a service. What is the most correct implementation pattern?

APut all the complex logic directly in the handler for the fastest possible response time
BCall printf() and system() from within the handler — they are standard library functions
CSet a global volatile flag in the handler; check and clear it in the main loop where full library access is safe
DUse a nested signal handler inside the first to process the complex work
Question 3 True / False

A signal blocked via sigprocmask() is not discarded — it is held pending and delivered when the mask is lifted.

TTrue
FFalse
Question 4 True / False

SIGKILL can be caught by installing a custom signal handler, allowing a process to perform cleanup before exiting.

TTrue
FFalse
Question 5 Short Answer

Why must signal handlers be 'async-signal-safe,' and what does this restriction mean in practice?

Think about your answer, then reveal below.