Blame man2/signalfd.2

Packit 7cfc04
.\" Copyright (C) 2008 Michael Kerrisk <mtk.manpages@gmail.com>
Packit 7cfc04
.\" starting from a version by Davide Libenzi <davidel@xmailserver.org>
Packit 7cfc04
.\"
Packit 7cfc04
.\" %%%LICENSE_START(GPLv2+_SW_3_PARA)
Packit 7cfc04
.\" This program is free software; you can redistribute it and/or modify
Packit 7cfc04
.\" it under the terms of the GNU General Public License as published by
Packit 7cfc04
.\" the Free Software Foundation; either version 2 of the License, or
Packit 7cfc04
.\" (at your option) any later version.
Packit 7cfc04
.\"
Packit 7cfc04
.\" This program is distributed in the hope that it will be useful,
Packit 7cfc04
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 7cfc04
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
Packit 7cfc04
.\" GNU General Public License for more details.
Packit 7cfc04
.\"
Packit 7cfc04
.\" You should have received a copy of the GNU General Public
Packit 7cfc04
.\" License along with this manual; if not, see
Packit 7cfc04
.\" <http://www.gnu.org/licenses/>.
Packit 7cfc04
.\" %%%LICENSE_END
Packit 7cfc04
.\"
Packit 7cfc04
.TH SIGNALFD 2 2017-05-03 Linux "Linux Programmer's Manual"
Packit 7cfc04
.SH NAME
Packit 7cfc04
signalfd \- create a file descriptor for accepting signals
Packit 7cfc04
.SH SYNOPSIS
Packit 7cfc04
.B #include <sys/signalfd.h>
Packit 7cfc04
.PP
Packit 7cfc04
.BI "int signalfd(int " fd ", const sigset_t *" mask ", int " flags );
Packit 7cfc04
.SH DESCRIPTION
Packit 7cfc04
.BR signalfd ()
Packit 7cfc04
creates a file descriptor that can be used to accept signals
Packit 7cfc04
targeted at the caller.
Packit 7cfc04
This provides an alternative to the use of a signal handler or
Packit 7cfc04
.BR sigwaitinfo (2),
Packit 7cfc04
and has the advantage that the file descriptor may be monitored by
Packit 7cfc04
.BR select (2),
Packit 7cfc04
.BR poll (2),
Packit 7cfc04
and
Packit 7cfc04
.BR epoll (7).
Packit 7cfc04
.PP
Packit 7cfc04
The
Packit 7cfc04
.I mask
Packit 7cfc04
argument specifies the set of signals that the caller
Packit 7cfc04
wishes to accept via the file descriptor.
Packit 7cfc04
This argument is a signal set whose contents can be initialized
Packit 7cfc04
using the macros described in
Packit 7cfc04
.BR sigsetops (3).
Packit 7cfc04
Normally, the set of signals to be received via the
Packit 7cfc04
file descriptor should be blocked using
Packit 7cfc04
.BR sigprocmask (2),
Packit 7cfc04
to prevent the signals being handled according to their default
Packit 7cfc04
dispositions.
Packit 7cfc04
It is not possible to receive
Packit 7cfc04
.B SIGKILL
Packit 7cfc04
or
Packit 7cfc04
.B SIGSTOP
Packit 7cfc04
signals via a signalfd file descriptor;
Packit 7cfc04
these signals are silently ignored if specified in
Packit 7cfc04
.IR mask .
Packit 7cfc04
.PP
Packit 7cfc04
If the
Packit 7cfc04
.I fd
Packit 7cfc04
argument is \-1,
Packit 7cfc04
then the call creates a new file descriptor and associates the
Packit 7cfc04
signal set specified in
Packit 7cfc04
.I mask
Packit 7cfc04
with that file descriptor.
Packit 7cfc04
If
Packit 7cfc04
.I fd
Packit 7cfc04
is not \-1,
Packit 7cfc04
then it must specify a valid existing signalfd file descriptor, and
Packit 7cfc04
.I mask
Packit 7cfc04
is used to replace the signal set associated with that file descriptor.
Packit 7cfc04
.PP
Packit 7cfc04
Starting with Linux 2.6.27, the following values may be bitwise ORed in
Packit 7cfc04
.IR flags
Packit 7cfc04
to change the behavior of
Packit 7cfc04
.BR signalfd ():
Packit 7cfc04
.TP 14
Packit 7cfc04
.B SFD_NONBLOCK
Packit 7cfc04
Set the
Packit 7cfc04
.BR O_NONBLOCK
Packit 7cfc04
file status flag on the new open file description.
Packit 7cfc04
Using this flag saves extra calls to
Packit 7cfc04
.BR fcntl (2)
Packit 7cfc04
to achieve the same result.
Packit 7cfc04
.TP
Packit 7cfc04
.B SFD_CLOEXEC
Packit 7cfc04
Set the close-on-exec
Packit 7cfc04
.RB ( FD_CLOEXEC )
Packit 7cfc04
flag on the new file descriptor.
Packit 7cfc04
See the description of the
Packit 7cfc04
.B O_CLOEXEC
Packit 7cfc04
flag in
Packit 7cfc04
.BR open (2)
Packit 7cfc04
for reasons why this may be useful.
Packit 7cfc04
.PP
Packit 7cfc04
In Linux up to version 2.6.26, the
Packit 7cfc04
.I flags
Packit 7cfc04
argument is unused, and must be specified as zero.
Packit 7cfc04
.PP
Packit 7cfc04
.BR signalfd ()
Packit 7cfc04
returns a file descriptor that supports the following operations:
Packit 7cfc04
.TP
Packit 7cfc04
.BR read (2)
Packit 7cfc04
If one or more of the signals specified in
Packit 7cfc04
.I mask
Packit 7cfc04
is pending for the process, then the buffer supplied to
Packit 7cfc04
.BR read (2)
Packit 7cfc04
is used to return one or more
Packit 7cfc04
.I signalfd_siginfo
Packit 7cfc04
structures (see below) that describe the signals.
Packit 7cfc04
The
Packit 7cfc04
.BR read (2)
Packit 7cfc04
returns information for as many signals as are pending and will
Packit 7cfc04
fit in the supplied buffer.
Packit 7cfc04
The buffer must be at least
Packit 7cfc04
.I "sizeof(struct signalfd_siginfo)"
Packit 7cfc04
bytes.
Packit 7cfc04
The return value of the
Packit 7cfc04
.BR read (2)
Packit 7cfc04
is the total number of bytes read.
Packit 7cfc04
.IP
Packit 7cfc04
As a consequence of the
Packit 7cfc04
.BR read (2),
Packit 7cfc04
the signals are consumed,
Packit 7cfc04
so that they are no longer pending for the process
Packit 7cfc04
(i.e., will not be caught by signal handlers,
Packit 7cfc04
and cannot be accepted using
Packit 7cfc04
.BR sigwaitinfo (2)).
Packit 7cfc04
.IP
Packit 7cfc04
If none of the signals in
Packit 7cfc04
.I mask
Packit 7cfc04
is pending for the process, then the
Packit 7cfc04
.BR read (2)
Packit 7cfc04
either blocks until one of the signals in
Packit 7cfc04
.I mask
Packit 7cfc04
is generated for the process,
Packit 7cfc04
or fails with the error
Packit 7cfc04
.B EAGAIN
Packit 7cfc04
if the file descriptor has been made nonblocking.
Packit 7cfc04
.TP
Packit 7cfc04
.BR poll "(2), " select "(2) (and similar)"
Packit 7cfc04
The file descriptor is readable
Packit 7cfc04
(the
Packit 7cfc04
.BR select (2)
Packit 7cfc04
.I readfds
Packit 7cfc04
argument; the
Packit 7cfc04
.BR poll (2)
Packit 7cfc04
.B POLLIN
Packit 7cfc04
flag)
Packit 7cfc04
if one or more of the signals in
Packit 7cfc04
.I mask
Packit 7cfc04
is pending for the process.
Packit 7cfc04
.IP
Packit 7cfc04
The signalfd file descriptor also supports the other file-descriptor
Packit 7cfc04
multiplexing APIs:
Packit 7cfc04
.BR pselect (2),
Packit 7cfc04
.BR ppoll (2),
Packit 7cfc04
and
Packit 7cfc04
.BR epoll (7).
Packit 7cfc04
.TP
Packit 7cfc04
.BR close (2)
Packit 7cfc04
When the file descriptor is no longer required it should be closed.
Packit 7cfc04
When all file descriptors associated with the same signalfd object
Packit 7cfc04
have been closed, the resources for object are freed by the kernel.
Packit 7cfc04
.SS The signalfd_siginfo structure
Packit 7cfc04
The format of the
Packit 7cfc04
.I signalfd_siginfo
Packit 7cfc04
structure(s) returned by
Packit 7cfc04
.BR read (2)s
Packit 7cfc04
from a signalfd file descriptor is as follows:
Packit 7cfc04
.PP
Packit 7cfc04
.in +4n
Packit 7cfc04
.EX
Packit 7cfc04
struct signalfd_siginfo {
Packit 7cfc04
    uint32_t ssi_signo;    /* Signal number */
Packit 7cfc04
    int32_t  ssi_errno;    /* Error number (unused) */
Packit 7cfc04
    int32_t  ssi_code;     /* Signal code */
Packit 7cfc04
    uint32_t ssi_pid;      /* PID of sender */
Packit 7cfc04
    uint32_t ssi_uid;      /* Real UID of sender */
Packit 7cfc04
    int32_t  ssi_fd;       /* File descriptor (SIGIO) */
Packit 7cfc04
    uint32_t ssi_tid;      /* Kernel timer ID (POSIX timers)
Packit 7cfc04
    uint32_t ssi_band;     /* Band event (SIGIO) */
Packit 7cfc04
    uint32_t ssi_overrun;  /* POSIX timer overrun count */
Packit 7cfc04
    uint32_t ssi_trapno;   /* Trap number that caused signal */
Packit 7cfc04
.\" ssi_trapno is unused on most arches
Packit 7cfc04
    int32_t  ssi_status;   /* Exit status or signal (SIGCHLD) */
Packit 7cfc04
    int32_t  ssi_int;      /* Integer sent by sigqueue(3) */
Packit 7cfc04
    uint64_t ssi_ptr;      /* Pointer sent by sigqueue(3) */
Packit 7cfc04
    uint64_t ssi_utime;    /* User CPU time consumed (SIGCHLD) */
Packit 7cfc04
    uint64_t ssi_stime;    /* System CPU time consumed
Packit 7cfc04
                              (SIGCHLD) */
Packit 7cfc04
    uint64_t ssi_addr;     /* Address that generated signal
Packit 7cfc04
                              (for hardware-generated signals) */
Packit 7cfc04
    uint16_t ssi_addr_lsb; /* Least significant bit of address
Packit 7cfc04
                              (SIGBUS; since Linux 2.6.37)
Packit 7cfc04
.\" ssi_addr_lsb: commit b8aeec34175fc8fe8b0d40efea4846dfc1ba663e
Packit 7cfc04
    uint8_t  pad[\fIX\fP];       /* Pad size to 128 bytes (allow for
Packit 7cfc04
                              additional fields in the future) */
Packit 7cfc04
};
Packit 7cfc04
.EE
Packit 7cfc04
.in
Packit 7cfc04
.PP
Packit 7cfc04
Each of the fields in this structure
Packit 7cfc04
is analogous to the similarly named field in the
Packit 7cfc04
.I siginfo_t
Packit 7cfc04
structure.
Packit 7cfc04
The
Packit 7cfc04
.I siginfo_t
Packit 7cfc04
structure is described in
Packit 7cfc04
.BR sigaction (2).
Packit 7cfc04
Not all fields in the returned
Packit 7cfc04
.I signalfd_siginfo
Packit 7cfc04
structure will be valid for a specific signal;
Packit 7cfc04
the set of valid fields can be determined from the value returned in the
Packit 7cfc04
.I ssi_code
Packit 7cfc04
field.
Packit 7cfc04
This field is the analog of the
Packit 7cfc04
.I siginfo_t
Packit 7cfc04
.I si_code
Packit 7cfc04
field; see
Packit 7cfc04
.BR sigaction (2)
Packit 7cfc04
for details.
Packit 7cfc04
.SS fork(2) semantics
Packit 7cfc04
After a
Packit 7cfc04
.BR fork (2),
Packit 7cfc04
the child inherits a copy of the signalfd file descriptor.
Packit 7cfc04
A
Packit 7cfc04
.BR read (2)
Packit 7cfc04
from the file descriptor in the child will return information
Packit 7cfc04
about signals queued to the child.
Packit 7cfc04
.SS Semantics of file descriptor passing
Packit 7cfc04
As with other file descriptors,
Packit 7cfc04
signalfd file descriptors can be passed to another process
Packit 7cfc04
via a UNIX domain socket (see
Packit 7cfc04
.BR unix (7)).
Packit 7cfc04
In the receiving process, a
Packit 7cfc04
.BR read (2)
Packit 7cfc04
from the received file descriptor will return information
Packit 7cfc04
about signals queued to that process.
Packit 7cfc04
.SS execve(2) semantics
Packit 7cfc04
Just like any other file descriptor,
Packit 7cfc04
a signalfd file descriptor remains open across an
Packit 7cfc04
.BR execve (2),
Packit 7cfc04
unless it has been marked for close-on-exec (see
Packit 7cfc04
.BR fcntl (2)).
Packit 7cfc04
Any signals that were available for reading before the
Packit 7cfc04
.BR execve (2)
Packit 7cfc04
remain available to the newly loaded program.
Packit 7cfc04
(This is analogous to traditional signal semantics,
Packit 7cfc04
where a blocked signal that is pending remains pending across an
Packit 7cfc04
.BR execve (2).)
Packit 7cfc04
.SS Thread semantics
Packit 7cfc04
The semantics of signalfd file descriptors in a multithreaded program
Packit 7cfc04
mirror the standard semantics for signals.
Packit 7cfc04
In other words,
Packit 7cfc04
when a thread reads from a signalfd file descriptor,
Packit 7cfc04
it will read the signals that are directed to the thread
Packit 7cfc04
itself and the signals that are directed to the process
Packit 7cfc04
(i.e., the entire thread group).
Packit 7cfc04
(A thread will not be able to read signals that are directed
Packit 7cfc04
to other threads in the process.)
Packit 7cfc04
.SH RETURN VALUE
Packit 7cfc04
On success,
Packit 7cfc04
.BR signalfd ()
Packit 7cfc04
returns a signalfd file descriptor;
Packit 7cfc04
this is either a new file descriptor (if
Packit 7cfc04
.I fd
Packit 7cfc04
was \-1), or
Packit 7cfc04
.I fd
Packit 7cfc04
if
Packit 7cfc04
.I fd
Packit 7cfc04
was a valid signalfd file descriptor.
Packit 7cfc04
On error, \-1 is returned and
Packit 7cfc04
.I errno
Packit 7cfc04
is set to indicate the error.
Packit 7cfc04
.SH ERRORS
Packit 7cfc04
.TP
Packit 7cfc04
.B EBADF
Packit 7cfc04
The
Packit 7cfc04
.I fd
Packit 7cfc04
file descriptor is not a valid file descriptor.
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
.I fd
Packit 7cfc04
is not a valid signalfd file descriptor.
Packit 7cfc04
.\" or, the
Packit 7cfc04
.\" .I sizemask
Packit 7cfc04
.\" argument is not equal to
Packit 7cfc04
.\" .IR sizeof(sigset_t) ;
Packit 7cfc04
.TP
Packit 7cfc04
.B EINVAL
Packit 7cfc04
.I flags
Packit 7cfc04
is invalid;
Packit 7cfc04
or, in Linux 2.6.26 or earlier,
Packit 7cfc04
.I flags
Packit 7cfc04
is nonzero.
Packit 7cfc04
.TP
Packit 7cfc04
.B EMFILE
Packit 7cfc04
The per-process limit on the number of open file descriptors has been reached.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENFILE
Packit 7cfc04
The system-wide limit on the total number of open files has been
Packit 7cfc04
reached.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENODEV
Packit 7cfc04
Could not mount (internal) anonymous inode device.
Packit 7cfc04
.TP
Packit 7cfc04
.B ENOMEM
Packit 7cfc04
There was insufficient memory to create a new signalfd file descriptor.
Packit 7cfc04
.SH VERSIONS
Packit 7cfc04
.BR signalfd ()
Packit 7cfc04
is available on Linux since kernel 2.6.22.
Packit 7cfc04
Working support is provided in glibc since version 2.8.
Packit 7cfc04
.\" signalfd() is in glibc 2.7, but reportedly does not build
Packit 7cfc04
The
Packit 7cfc04
.BR signalfd4 ()
Packit 7cfc04
system call (see NOTES) is available on Linux since kernel 2.6.27.
Packit 7cfc04
.SH CONFORMING TO
Packit 7cfc04
.BR signalfd ()
Packit 7cfc04
and
Packit 7cfc04
.BR signalfd4 ()
Packit 7cfc04
are Linux-specific.
Packit 7cfc04
.SH NOTES
Packit 7cfc04
A process can create multiple signalfd file descriptors.
Packit 7cfc04
This makes it possible to accept different signals
Packit 7cfc04
on different file descriptors.
Packit 7cfc04
(This may be useful if monitoring the file descriptors using
Packit 7cfc04
.BR select (2),
Packit 7cfc04
.BR poll (2),
Packit 7cfc04
or
Packit 7cfc04
.BR epoll (7):
Packit 7cfc04
the arrival of different signals will make different file descriptors ready.)
Packit 7cfc04
If a signal appears in the
Packit 7cfc04
.I mask
Packit 7cfc04
of more than one of the file descriptors, then occurrences
Packit 7cfc04
of that signal can be read (once) from any one of the file descriptors.
Packit 7cfc04
.PP
Packit 7cfc04
Attempts to include
Packit 7cfc04
.B SIGKILL
Packit 7cfc04
and
Packit 7cfc04
.B SIGSTOP
Packit 7cfc04
in
Packit 7cfc04
.I mask
Packit 7cfc04
are silently ignored.
Packit 7cfc04
.PP
Packit 7cfc04
The signal mask employed by a signalfd file descriptor can be viewed
Packit 7cfc04
via the entry for the corresponding file descriptor in the process's
Packit 7cfc04
.IR /proc/[pid]/fdinfo
Packit 7cfc04
directory.
Packit 7cfc04
See
Packit 7cfc04
.BR proc (5)
Packit 7cfc04
for further details.
Packit 7cfc04
.\"
Packit 7cfc04
.SS Limitations
Packit 7cfc04
The signalfd mechanism can't be used to receive signals that
Packit 7cfc04
are synchronously generated, such as the
Packit 7cfc04
.BR SIGSEGV
Packit 7cfc04
signal that results from accessing an invalid memory address
Packit 7cfc04
or the
Packit 7cfc04
.BR SIGFPE
Packit 7cfc04
signal that results from an arithmetic error.
Packit 7cfc04
Such signals can be caught only via signal handler.
Packit 7cfc04
.PP
Packit 7cfc04
As described above,
Packit 7cfc04
in normal usage one blocks the signals that will be accepted via
Packit 7cfc04
.BR signalfd ().
Packit 7cfc04
If spawning a child process to execute a helper program
Packit 7cfc04
(that does not need the signalfd file descriptor),
Packit 7cfc04
then, after the call to
Packit 7cfc04
.BR fork (2),
Packit 7cfc04
you will normally want to unblock those signals before calling
Packit 7cfc04
.BR execve (2),
Packit 7cfc04
so that the helper program can see any signals that it expects to see.
Packit 7cfc04
Be aware, however,
Packit 7cfc04
that this won't be possible in the case of a helper program spawned
Packit 7cfc04
behind the scenes by any library function that the program may call.
Packit 7cfc04
In such cases, one must fall back to using a traditional signal
Packit 7cfc04
handler that writes to a file descriptor monitored by
Packit 7cfc04
.BR select (2),
Packit 7cfc04
.BR poll (2),
Packit 7cfc04
or
Packit 7cfc04
.BR epoll (7),
Packit 7cfc04
.\"
Packit 7cfc04
.SS C library/kernel differences
Packit 7cfc04
The underlying Linux system call requires an additional argument,
Packit 7cfc04
.IR "size_t sizemask" ,
Packit 7cfc04
which specifies the size of the
Packit 7cfc04
.I mask
Packit 7cfc04
argument.
Packit 7cfc04
The glibc
Packit 7cfc04
.BR signalfd ()
Packit 7cfc04
wrapper function does not include this argument,
Packit 7cfc04
since it provides the required value for the underlying system call.
Packit 7cfc04
.PP
Packit 7cfc04
There are two underlying Linux system calls:
Packit 7cfc04
.BR signalfd ()
Packit 7cfc04
and the more recent
Packit 7cfc04
.BR signalfd4 ().
Packit 7cfc04
The former system call does not implement a
Packit 7cfc04
.I flags
Packit 7cfc04
argument.
Packit 7cfc04
The latter system call implements the
Packit 7cfc04
.I flags
Packit 7cfc04
values described above.
Packit 7cfc04
Starting with glibc 2.9, the
Packit 7cfc04
.BR signalfd ()
Packit 7cfc04
wrapper function will use
Packit 7cfc04
.BR signalfd4 ()
Packit 7cfc04
where it is available.
Packit 7cfc04
.SH BUGS
Packit 7cfc04
In kernels before 2.6.25, the
Packit 7cfc04
.I ssi_ptr
Packit 7cfc04
and
Packit 7cfc04
.I ssi_int
Packit 7cfc04
fields are not filled in with the data accompanying a signal sent by
Packit 7cfc04
.BR sigqueue (3).
Packit 7cfc04
.\" The fix also was put into 2.6.24.5
Packit 7cfc04
.SH EXAMPLE
Packit 7cfc04
The program below accepts the signals
Packit 7cfc04
.B SIGINT
Packit 7cfc04
and
Packit 7cfc04
.B SIGQUIT
Packit 7cfc04
via a signalfd file descriptor.
Packit 7cfc04
The program terminates after accepting a
Packit 7cfc04
.B SIGQUIT
Packit 7cfc04
signal.
Packit 7cfc04
The following shell session demonstrates the use of the program:
Packit 7cfc04
.PP
Packit 7cfc04
.in +4n
Packit 7cfc04
.EX
Packit 7cfc04
.RB "$" " ./signalfd_demo"
Packit 7cfc04
.BR "^C" "                   # Control\-C generates SIGINT"
Packit 7cfc04
Got SIGINT
Packit 7cfc04
.B ^C
Packit 7cfc04
Got SIGINT
Packit 7cfc04
\fB^\\\fP                    # Control\-\\ generates SIGQUIT
Packit 7cfc04
Got SIGQUIT
Packit 7cfc04
$
Packit 7cfc04
.EE
Packit 7cfc04
.in
Packit 7cfc04
.SS Program source
Packit 7cfc04
\&
Packit 7cfc04
.EX
Packit 7cfc04
#include <sys/signalfd.h>
Packit 7cfc04
#include <signal.h>
Packit 7cfc04
#include <unistd.h>
Packit 7cfc04
#include <stdlib.h>
Packit 7cfc04
#include <stdio.h>
Packit 7cfc04
Packit 7cfc04
#define handle_error(msg) \\
Packit 7cfc04
    do { perror(msg); exit(EXIT_FAILURE); } while (0)
Packit 7cfc04
Packit 7cfc04
int
Packit 7cfc04
main(int argc, char *argv[])
Packit 7cfc04
{
Packit 7cfc04
    sigset_t mask;
Packit 7cfc04
    int sfd;
Packit 7cfc04
    struct signalfd_siginfo fdsi;
Packit 7cfc04
    ssize_t s;
Packit 7cfc04
Packit 7cfc04
    sigemptyset(&mask);
Packit 7cfc04
    sigaddset(&mask, SIGINT);
Packit 7cfc04
    sigaddset(&mask, SIGQUIT);
Packit 7cfc04
Packit 7cfc04
    /* Block signals so that they aren\(aqt handled
Packit 7cfc04
       according to their default dispositions */
Packit 7cfc04
Packit 7cfc04
    if (sigprocmask(SIG_BLOCK, &mask, NULL) == \-1)
Packit 7cfc04
        handle_error("sigprocmask");
Packit 7cfc04
Packit 7cfc04
    sfd = signalfd(\-1, &mask, 0);
Packit 7cfc04
    if (sfd == \-1)
Packit 7cfc04
        handle_error("signalfd");
Packit 7cfc04
Packit 7cfc04
    for (;;) {
Packit 7cfc04
        s = read(sfd, &fdsi, sizeof(struct signalfd_siginfo));
Packit 7cfc04
        if (s != sizeof(struct signalfd_siginfo))
Packit 7cfc04
            handle_error("read");
Packit 7cfc04
Packit 7cfc04
        if (fdsi.ssi_signo == SIGINT) {
Packit 7cfc04
            printf("Got SIGINT\\n");
Packit 7cfc04
        } else if (fdsi.ssi_signo == SIGQUIT) {
Packit 7cfc04
            printf("Got SIGQUIT\\n");
Packit 7cfc04
            exit(EXIT_SUCCESS);
Packit 7cfc04
        } else {
Packit 7cfc04
            printf("Read unexpected signal\\n");
Packit 7cfc04
        }
Packit 7cfc04
    }
Packit 7cfc04
}
Packit 7cfc04
.EE
Packit 7cfc04
.SH SEE ALSO
Packit 7cfc04
.BR eventfd (2),
Packit 7cfc04
.BR poll (2),
Packit 7cfc04
.BR read (2),
Packit 7cfc04
.BR select (2),
Packit 7cfc04
.BR sigaction (2),
Packit 7cfc04
.BR sigprocmask (2),
Packit 7cfc04
.BR sigwaitinfo (2),
Packit 7cfc04
.BR timerfd_create (2),
Packit 7cfc04
.BR sigsetops (3),
Packit 7cfc04
.BR sigwait (3),
Packit 7cfc04
.BR epoll (7),
Packit 7cfc04
.BR signal (7)
Packit 7cfc04
.SH COLOPHON
Packit 7cfc04
This page is part of release 4.15 of the Linux
Packit 7cfc04
.I man-pages
Packit 7cfc04
project.
Packit 7cfc04
A description of the project,
Packit 7cfc04
information about reporting bugs,
Packit 7cfc04
and the latest version of this page,
Packit 7cfc04
can be found at
Packit 7cfc04
\%https://www.kernel.org/doc/man\-pages/.