Home

signalfd

Signalfd is a Linux-specific interface that provides a file descriptor for receiving signals. It allows a process to deliver signals through normal I/O multiplexing mechanisms (such as poll, epoll, or select) rather than through traditional asynchronous signal handlers. By creating a signalfd, a program can read signal information from a file descriptor just like reading data from a socket or pipe.

Operation and usage: A process typically blocks the signals it wants to receive through a signalfd using

Variants and flags: The signalfd interface has wrappers such as signalfd and signalfd4. signalfd4 supports additional

Portability and scope: signalfd is available only on Linux; it is not part of the POSIX standard.

See also: sigprocmask, signalfd4, sigaction.

sigprocmask,
then
creates
a
signalfd
(or
signalfd4)
with
a
mask
that
specifies
the
signals
to
trap.
The
resulting
file
descriptor
becomes
readable
when
a
signal
in
that
set
is
generated
for
the
process.
The
program
reads
signalfd_siginfo
data
from
the
descriptor,
which
contains
information
about
the
delivered
signal
(for
example,
the
signal
number)
and
may
include
sender
details
such
as
the
originating
process
ID
and
user
ID.
After
reading,
the
signal
event
is
consumed
and
can
be
processed
by
the
program
in
its
event
loop.
flags
(for
example,
non-blocking
and
close-on-exec).
The
file
descriptor
can
be
monitored
with
standard
IO
multiplexing
calls,
and
it
can
be
used
alongside
other
event
sources
in
multi-threaded
or
multi-process
programs.
It
is
commonly
used
in
event-driven
software,
daemons,
and
servers
where
unified
handling
of
IO
and
signals
is
desirable.