Linux:...:Signal(3pm)
π Linux::FD::Signal β signal filehandles for Linux, bestie π
okay so real talk: this is Linux::FD::Signal, a Perl module, and it's currently sitting at version 0.017. we're talking about Perl here, so obviously it's 3pm-coded, iykyk π
β¨ SYNOPSIS β¨
like, here's the whole vibe in two lines:
use Linux::FD::Signal;
my $fh = Linux::FD::Signal->new($sigset, @flags);
that's it. that's the whole thing. you make a filehandle and it catches signals for you. iconic behavior honestly π
πΈ DESCRIPTION πΈ
so basically this module hands you a filehandle that accepts signals aimed at you, the caller. it's similar but not identical to Signal::Pipe β not a copy, not a remix, its own whole thing π¦
it's an alternative to the old-school way of doing things: conventional signal handlers, or sigwaitinfo. and the glow-up here? the file descriptor is easy to monitor with stuff like select, poll, and epoll. main character energy fr fr π
π METHODS π
π new($sigmask)
the $sigmask argument is the set of signals you want to accept through this file descriptor. it should be either a signal name (no SIG prefix, bestie) or a POSIX::SigSet object.
normally you want the set of signals you're receiving via the file descriptor to be blocked β otherwise they get handled according to their default dispositions and that's not the moment.
and okay, important: you literally cannot receive SIGKILL or SIGSTOP signals through a signalfd file descriptor. if you put them in $sigmask, they are silently ignored. no error, no drama, they just ghost you π
@flags is an optional list of flags, and right now it's limited to exactly one: 'non-blocking' β and heads up, that one requires Linux 2.6.27. no cap.
π§ set_mask($sigmask)
sets the signal mask to a new value. the argument works exactly the same as new's does. same rules, same vibes, same SIGKILL/SIGSTOP situation. π«Ά
π receive()
okay so here's the moment. if one or more of the signals in your mask is pending for the process, this returns the info from one signalfd_siginfo structure (see below) describing those signals.
as a consequence of the receive, the signals are consumed β so they're no longer pending for the process. that means:
- they will not be caught by signal handlers
- they cannot be accepted using
sigwaitinfo
they're gone, bestie. eaten. π
if none of the signals in the mask is pending for the process, then receive either:
- blocks until one of the signals in mask is generated for the process, or
- fails with the error
EAGAINif the file descriptor has been made non-blocking
and the info comes back as a hashref with these keys:
signo, errno, code, pid, uid, fd, tid, band, overrun, trapno, status, int, ptr, utime, stime, address
all of these come back as integers. some of them are only useful in certain circumstances, and others might not be useful from perl at all. that's just how it is. π€·
β SEE ALSO β
Signal::Mask
π AUTHOR π
Leon Timmermans <leont@cpan.org>
π COPYRIGHT AND LICENSE π
this software is copyright (c) 2010 by Leon Timmermans.
this is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
and that's the whole page, babe π written up against perl v5.40.1, dated 2025-04-19, for the Linux:...:Signal(3pm) manual β go block some signals and slay β¨πΈ
π¦ where this page comes from
- debian trixie: liblinux-fd-perl 0.017-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: liblinux-fd-perl 0.017-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms