The signalfd(2) API

The reader will recall that, in Chapter 1, Linux System Architecture, in the section entitled, The Unix philosophy in a nutshell, we drove home the point that a cornerstone of the Unix philosophy is this:

On Unix, everything is a process; if it's not a process, it's a file.

Experienced Unix and Linux developers are very used to the idea (abstraction, really) of treating stuff as if it were a file; this includes devices, pipes, and sockets. Why not signals?

That's precisely the idea behind the signalfd(2) system call; with signalfd, you can create a file descriptor and associate it with a signal set. Now, the application programmer is free to monitor signals using a variety of familiar file-based APIs—among them the

Get Hands-On System Programming with Linux now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.