SIGRETURN(2)
π SIGRETURN(2) π
okay bestie, gather round, we're talking about the System Calls Manual, section 2 β this one's called sigreturn, and it's literally the "return from signal" girlie. β¨
πΈ NAME πΈ
sigreturn β return from signal π«Ά
π LIBRARY π
Standard C Library (libc, -lc) β she lives in libc, obviously. π
π¦ SYNOPSIS π¦
#include <signal.h>
int
sigreturn(const ucontext_t *scp);
β¨ DESCRIPTION β¨
so the sigreturn() system call is the one that lets users atomically unmask, switch stacks, and return from a signal context. all three, at once, no gaps, no mess. iconic behavior honestly. π
The thread's signal mask and stack status get restored from the context structure that scp points to. and here's the wild part β the system call does not return. like, it's not coming back. it's giving "I'm not stuck here with you, you're stuck here with me" energy. π
Instead, the users stack pointer, frame pointer, argument pointer, and processor status longword all get restored from the context, and execution resumes at the specified pc. so it justβ¦ teleports you back to where you were. main character re-entry. π
This system call is what the trampoline code uses, and also longjmp(3), when returning from a signal to the previously executing program. bestie duo fr fr. π
β RETURN VALUES β
If successful, the system call does not return. full stop, no return value, she's gone.
Otherwise β so, if it doesn't work β a value of -1 is returned and errno is set to indicate the error. π©
π ERRORS π
The sigreturn() system call will fail and the thread context will remain unchanged if one of the following occurs. (yes, unchanged β no half-done vibes here.)
[EFAULT]β thescpargument points to memory that is not a valid part of the process address space. like, that's not your memory babe, that's not your address space. π[EINVAL]β the process status longword is invalid, or it would improperly raise the privilege level of the process. so either it's nonsense, or it's trying to sneakily level up privileges it does not deserve. not on our watch. π«
π SEE ALSO π
π§ HISTORY π§
The sigreturn() system call appeared in 4.3BSD. vintage. classic. the blueprint. π
and that's the whole page bestie!! π this was the Debian build of the manual, dated September 6, 2013 β so it's an old-money manpage and it still ate. mwah. πβ¨
π¦ 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) 1985, 1991, 1993 The Regents of the University of California. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms