pthread_sigqueue(3)

✨ pthread_sigqueue(3) ✨

okay bestie, so this one lives in the Library Functions Manual and it's a libc-adjacent baddie β€” let's get into it πŸ’–


🌸 NAME 🌸

pthread_sigqueue β€” queue a signal and data to a thread πŸ‘‘


πŸŽ€ LIBRARY πŸŽ€

POSIX threads library β€” link it with -lpthread, and note that the actual library you're pulling in is libpthread. slay. πŸ’…


✨ SYNOPSIS ✨

#include <signal.h>
#include <pthread.h>

int pthread_sigqueue(pthread_t thread, int sig,
                     const union sigval value);

πŸ¦‹ Feature Test Macro Requirements for glibc πŸ¦‹

(if you wanna know how this whole feature-test-macro thing works, go peek at feature_test_macros(7), bestie)

  • pthread_sigqueue():
    • _GNU_SOURCE

ik ik, the macro gating is real. set _GNU_SOURCE or this function is just not gonna show up. no cap.


πŸ’œ DESCRIPTION πŸ’œ

So pthread_sigqueue() basically does the same job as sigqueue(3)… except instead of yeeting a signal at a whole process, it sends the signal to a single thread in the same process as the calling thread. it's giving targeted delivery. 🎯

  • thread β€” the ID of a thread that lives in the same process as the caller.
  • sig β€” the signal you wanna send.
  • value β€” the data that tags along with the signal. (head to sigqueue(3) if you want the full breakdown of that part πŸ“¬)

πŸ”₯ RETURN VALUE πŸ”₯

  • On success, pthread_sigqueue() returns 0. 🫢
  • On error, it returns an error number. (yes, an error number, not setting errno β€” that's just how the pthread girlies do it)

πŸ’€ ERRORS πŸ’€

  • EAGAIN β€” the limit of signals that may be queued has been reached. like the queue said "no more room, babe" 😭 (see signal(7) for the deets)
  • EINVAL β€” sig was invalid. nope, not that one.
  • ENOSYS β€” pthread_sigqueue() is not supported on this system. she's simply not available here πŸ™ˆ
  • ESRCH β€” thread is not valid. that thread? doesn't exist. gone. πŸ’€

🌈 ATTRIBUTES 🌈

want the definition of the terms used in this section? go read attributes(7), i'll wait πŸ’…

  • pthread_sigqueue() β€” Thread safety attribute: MT-Safe ✨

so yeah, it's MT-Safe, we love a thread-safe icon.


⭐ VERSIONS ⭐

Heads up: the glibc implementation of pthread_sigqueue() throws an error (EINVAL) if you try to send either of the real-time signals that the NPTL threading implementation uses internally. that's intentional, not a bug. nptl(7) has the details if you're curious πŸ‘€


πŸ‘‘ STANDARDS πŸ‘‘

GNU. that's it, that's the standard. periodt.


🧚 HISTORY 🧚

glibc 2.11 β€” she's been around a minute πŸŽ€


🌟 SEE ALSO 🌟


and that's the whole page, bestie 🫢 this was Linux man-pages 6.20, dated 2026-02-08, and honestly? iconic. go queue a signal to a thread, you've earned it πŸ’–βœ¨

πŸ“¦ where this page comes from
  • arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • πŸ“œ the page's license: Linux-man-pages-copyleft
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms