EXIT(2)
π EXIT(2) β System Calls Manual π
okay bestie, sit DOWN, because we're talking about _exit from section 2 of the manual, and honestly? it's giving "the final boss of process life cycles." π¦
β¨ NAME β¨
_exit β terminate the calling process π
no like. that's it. that's the whole job. iconic behavior fr fr.
π LIBRARY π
Standard C Library (libc, -lc)
so you just link it like a normal person and you're good π«Ά
π SYNOPSIS π
#include <unistd.h>
void
_exit(int status);
πΈ DESCRIPTION πΈ
The _exit() system call terminates a process, and it comes with a whole little consequence list, so let's get into it, bestie, because this is NOT a "just vibe and leave" situation:
- All of the descriptors open in the calling process are closed. This may entail delays, for example, waiting for output to drain; a process in this state may not be killed, as it is already dying. likeβ¦ you cannot kill what is already leaving. it's in its departure era. periodt. π
- If the parent process of the calling process has an outstanding
wait(2)call or catches theSIGCHLDsignal, it is notified of the calling process's termination and thestatusis set as defined bywait(2). π so your parent gets the text message. - The parent process-ID of all of the calling process's existing child processes are set to the process-ID of the calling process's reaper; the reaper (normally the initialization process) inherits each of these processes (see
procctl(2),init(8)and the βDEFINITIONSβ section ofintro(2)). π§ so your kids get adopted, no cap. - If the termination of the process causes any process group to become orphaned (usually because the parents of all members of the group have now exited; see βorphaned process groupβ in
intro(2)), and if any member of the orphaned group is stopped, theSIGHUPsignal and theSIGCONTsignal are sent to all members of the newly-orphaned process group. π₯ ok dramatic but necessary. - If the process is a controlling process (see
intro(2)), theSIGHUPsignal is sent to the foreground process group of the controlling terminal, and all current access to the controlling terminal is revoked. π rip to the terminal access, it's gone, it's deleted.
Most C programs call the library routine exit(3), which flushes buffers, closes streams, unlinks temporary files, etc., before calling _exit().
bestie PLEASE remember this.exit(3)is the one that tidies up first._exit()is the one that just πββοΈπ¨ leaves immediately. iykyk.
β RETURN VALUES β
The _exit() system call can never return. π
literally cannot. it's not being rude, it's just physically incapable. once you call it you're gone, that's the whole bit. no return value, no comeback, no redemption arc. π
π¦ SEE ALSO π¦
fork(2), sigaction(2), wait(2), exit(3), init(8)
(the whole friend group, honestly π«Ά)
π STANDARDS π
The _exit() system call is expected to conform to ISO/IEC 9945-1:1990 (βPOSIX.1β). β¨
π HISTORY π
The _exit() function appeared in Version 7 AT&T UNIX. so it's a legacy queen, an OG, we stan a function with lore. π
okay that's the whole page bestie!! this one came from the Debian peeps, dated September 8, 2016, and it lives at EXIT(2) in the System Calls Manual β mwah, take care of your processes, love u, bye!! ππΈπ¦
π¦ 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) 1980, 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