The
The following program establishes a handler for SIGINT and then enters an infinite loop. To demonstrate that the kernel does not queue traditional signals, we use sigprocmask to block SIGINT at the start of the loop, and unblock it at the end: no matter how many SIGINTs we send the process while it is executing the loop body (the sleep), the kernel will only deliver one of these signals at the top of the loop.
Our handler uses the siginfo_t argument to print additional information about the signal, such as the si_code which indicates who sent the signal. In the event that a user process (such as the kill utility) sent us the signal, handler also prints the UID and PID of that process.