GETSID(2)
π GETSID π
okay so bestie, welcome to the GETSID(2) page, straight outta the System Calls Manual, and no cap this one is a lil cutie. she's short, she's sweet, she tells you which session a process belongs to. that's it. that's the whole vibe. π¦
β¨ NAME β¨
getsid β get process session π
π LIBRARY π
Standard C Library (libc, -lc) β yeah girl, it's just chillin in libc, you don't need to link anything special.
πΈ SYNOPSIS πΈ
#include <unistd.h>
pid_t
getsid(pid_t pid);
π DESCRIPTION π
So here's the tea: the session ID of the process identified by pid is returned by getsid(). that's the whole job. she looks up your process, she finds its session, she hands you the number. iconic behavior honestly.
And if pid is zero? π«Ά then getsid() returns the session ID of the current process. like, she just assumes you mean yourself. main character energy fr fr.
π₯ RETURN VALUES π₯
Upon successful completion, the getsid() system call returns the session ID of the specified process. slay. π
otherwise?? it returns a value of -1 and sets errno to indicate an error. π so always check, bestie, always check.
π ERRORS π
The getsid() system call will succeed unless:
[ESRCH]β if there is no process with a process ID equal topid. like, she looked everywhere and that process simply does not exist. ghosted. π»
β οΈ Note that an implementation may restrict this system call to processes within the same session ID as the calling process. so lowkey she might not be allowed to peek outside her own session, depending on the implementation. not a bug, just how it be. π
π SEE ALSO π
go read those too, they're the whole friend group π
π HISTORY π
The getsid() system call appeared in FreeBSD 3.0. and plot twist: the getsid() system call is derived from its usage in AT&T System V UNIX. so she's old money, but she still serves. β¨
and that's the page, bestie!! written up by the Debian crew on August 19, 1997 β yeah, literally before some of us were born, but the info still hits π stay curious, read your man pages, and remember: check your return values. periodt. πππ¦
π¦ 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) 1997 Peter Wemm <peter@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms