Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

22. Signals: Advanced Features > Fetching Signals via a File Descriptor

Fetching Signals via a File Descriptor

Starting with kernel 2.6.22, Linux provides the (nonstandard) signalfd() system call, which creates a special file descriptor from which signals directed to the caller can be read. The signalfd mechanism provides an alternative to the use of sigwaitinfo() for synchronously accepting signals.

#include <sys/signalfd.h>

int signalfd(int fd, const sigset_t *maskl, int flags);

Note

Returns file descriptor on success, or -1 on error

The mask argument is a signal set that specifies the signals that we want to be able to read via the signalfd file descriptor. As with sigwaitinfo(), we should normally also block all of the signals in mask using sigprocmask(), so that the signals don’t get handled according to their default dispositions before we have a chance to read them.


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint