The following program demonstrates the use of the signalfd system call. signalfd is an alternative to sigwaitinfo that allows us to synchronously handle signals. Specifically, signalfd allows us to create a "file" descriptor, and to speicfy the set of signals the we want to handle via the descriptor. By default, reads from the descriptor block until one of the specified signals becomes pending. The read then returns in its buffer information about the signal.
The advantages of signalfd over sigwaitinfo are two-fold. First, whereas sigwaitinfo returns information about a single signal, the read operation on the signal descriptor can return information about more than one pending signal. Additionally, the signal descriptor is amenable to concurrency techniques (see select, poll, epoll) that are extremely useful when designing server applications.