PTHREAD_SUSPEND_NP(3)

πŸ“¦ version 15.1, in freebsd 14.5, freebsd 15.1, nixpkgs unstable

✨ PTHREAD_SUSPEND_NP ✨

okay so this is a page from the Library Functions Manual, and bestie, we're talking about pthread_suspend_np today β€” the little function that puts a thread to sleep on purpose πŸ’€ like it's taking a nap mid-group-chat.


πŸ’– NAME πŸ’–

pthread_suspend_np β€” suspend a thread 🫢


πŸŽ€ LIBRARY πŸŽ€

POSIX Threads Library (libpthread, -lpthread) β€” that's where she lives, no cap.


🌸 SYNOPSIS 🌸

#include <pthread_np.h>

int
pthread_suspend_np(pthread_t tid);

πŸ¦‹ DESCRIPTION πŸ¦‹

so like, pthread_suspend_np() is called on an active thread and it literally causes that thread to suspend. like, "girl, take a break" βœ‹ periodt.

⚠️ okay this part is important so pay attention bestie: it is not safe for the caller of pthread_suspend_np() to use any non-async signal safe functions β€” except pthread_resume_np(3) β€” until the suspended thread is resumed. unless, of course, measures are taken to ensure the thread is suspended at a safe point. no cap, this is the scary part 😭 don't just go calling random stuff after suspending a thread, it's giving undefined vibes.

🌈 RETURN VALUES 🌈

if it works, pthread_suspend_np() returns 0 β€” slay πŸ’… otherwise, an error number comes back at you to indicate the error. rude but okay.


πŸ”₯ ERRORS πŸ”₯

pthread_suspend_np() will fail if:

  • [EDEADLK] β€” an attempt was made to suspend the current thread πŸ’€ like girl you can't suspend yourself, that's not the vibe, main character energy gone wrong.
  • [EINVAL] β€” the value specified by the tid argument is invalid πŸ™ˆ not a real one bestie.
  • [ESRCH] β€” no thread could be found corresponding to the thread ID specified by the tid argument 😭 she's not here, she's gone, the thread ID matched nobody.

πŸ’œ SEE ALSO πŸ’œ

pthread_np(3), pthread_resume_all_np(3), pthread_resume_np(3), pthread_suspend_all_np(3) β€” the whole friend group, go read them too 🧚


πŸ‘‘ AUTHORS πŸ‘‘

this manual page was written by Alexey Zelkin <phantom@FreeBSD.org> β€” king behaviour, we stan 🫢⭐


okay that's the whole page, ily, go suspend some threads responsibly πŸ’–

Debian Β· October 12, 2021 Β· PTHREAD_SUSPEND_NP(3) β€” bye bestie, see you in the man pages πŸ’…πŸŽ€

πŸ“¦ where this page comes from