SIGQUEUE(2)
okay bestie, pull up a chair π«Ά because we're reading sigqueue(2) together β that's the sigqueue page from the System Calls Manual, section 2 energy, iykyk. It's giving realtime signal queueing and honestly? iconic. Let's get into it. π
β¨ NAME β¨
sigqueue β queue a signal to a process (REALTIME)
No cap, that's the whole vibe: you're shoving a signal into somebody's queue. π
π LIBRARY π
Standard C Library (libc, -lc)
Like, it's right there in libc, you don't have to go hunting. π¦
πΈ SYNOPSIS πΈ
#include <signal.h>
int
sigqueue(pid_t pid, int signo, const union sigval value);
π DESCRIPTION π
Okay so here's the tea. The sigqueue() system call causes the signal specified by signo to be sent with the value specified by value to the process specified by pid. Three little args, one big job. β¨
And listen β if signo is zero (that's the null signal, bestie), error checking is performed but no signal is actually sent. So it's basically a vibe check with zero follow-through π. The null signal can be used to check the validity of PID. Very "not me just checking if you're still alive" energy. π
The conditions required for a process to have permission to queue a signal to another process are the same as for the kill(2) system call. Same rules, same gatekeeping. The sigqueue() system call queues a signal to a single process specified by the pid argument β one process, one queue, periodt.
The sigqueue() system call returns immediately. It does not sit around waiting, it is not clingy. If the resources were available to queue the signal, the signal will be queued and sent to the receiving process. πββοΈπ¨
Now here's the part that's lowkey a lot, so read it slow:
If the value of pid causes signo to be generated for the sending process, and if signo is not blocked for the calling thread, and if no other thread has signo unblocked or is waiting in a sigwait() system call for signo, then either signo or at least the pending, unblocked signal will be delivered to the calling thread before sigqueue() returns.
Should any multiple pending signals in the range SIGRTMIN to SIGRTMAX be selected for delivery, it is the lowest numbered one. The selection order between realtime and non-realtime signals, or between multiple pending non-realtime signals, is unspecified. So likeβ¦ don't build your whole personality on predicting that order, fr fr. π
π«Ά RETURN VALUES π«Ά
Upon successful completion, the value 0 is returned; otherwise the value -1 is returned and the global variable errno is set to indicate the error. Classic. Iconic. The binary of it all. β¨
π ERRORS π
The sigqueue() system call will fail if:
[EAGAIN]β No resources are available to queue the signal. The process has already queued{SIGQUEUE_MAX}signals that are still pending at the receiver(s), or a system-wide resource limit has been exceeded. Like babe, the queue is full, there is no room at the inn. π[EINVAL]β The value of the signo argument is an invalid or unsupported signal number. That's not a signal, bestie, that's a typo. π[EPERM]β The process does not have the appropriate privilege to send the signal to the receiving process. Permission? Denied. Slay responsibly. π[ESRCH]β The process pid does not exist. Ghosted. Literally. π
π₯ SEE ALSO π₯
kill(2), sigaction(2), sigpending(2), sigsuspend(2), sigtimedwait(2), sigwait(2), sigwaitinfo(2), pause(3), pthread_sigmask(3), siginfo(3)
The whole signal friend group, all linked up. Go say hi. π¦
β STANDARDS β
The sigqueue() system call conforms to IEEE Std 1003.1-2004 (βPOSIX.1β). Standards-compliant AND cute, we love to see it. β¨
π HISTORY π
Support for POSIX realtime signal queue first appeared in FreeBSD 7.0. A little historical moment, a little glow-up. π
β οΈ CAVEATS β οΈ
Bestie, this part is important, don't skip it. π¨
When using sigqueue to send signals to a process which might have a different ABI (for instance, one is 32-bit and the other 64-bit), the sival_int member of value can be delivered reliably, but the sival_ptr may be truncated in endian dependent ways and must not be relied on.
Further, many pointer integrity schemes disallow sending pointers to other processes, and this technique should not be used in programs intended to be portable. So likeβ¦ it's giving "works on my machine" and not much else. π
and that's the whole page, you ate that π This one came to you from Debian, dated May 5, 2017 β shoutout to the maintainers, we love them for this. Now go queue a signal, you absolute main character. πβ¨π¦
π¦ where this page comes from
- debian bookworm: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- debian trixie: freebsd-manpages 12.2-2 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu jammy: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu noble: freebsd-manpages 12.2-1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu questing: freebsd-manpages 12.2-2
- ubuntu resolute: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- ubuntu stonking: freebsd-manpages 12.2-2build1 Β· BSD-2-Clause-FreeBSD AND BSD-4-Clause
- Copyright (c) 2005 David Xu <davidxu@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms