EXIT(3POSIX)
π¦ EXIT(3POSIX) β ok bestie, let's talk about ending it (a process) π
so this page is EXIT(3POSIX) from the POSIX Programmer's Manual β the C library's whole entire "bye, i'm out" function. sit with me, this one's short but it matters. π«Ά
β¨ PROLOG β¨
okay so first things first, housekeeping: this manual page is part of the POSIX Programmer's Manual. the Linux implementation of this interface may differ β and if you're on Linux, bestie, pls consult the corresponding Linux manual page for the details of Linux behavior. OR the interface may not even be implemented on Linux at all. π so like, vibe check your platform, yk?
π NAME π
exit β terminate a process
literally just. end the whole thing. the process. gone. π (in a good way, it's a graceful exit, we love her)
πΈ SYNOPSIS πΈ
#include <stdlib.h>
void exit(int status);
π DESCRIPTION π
so the functionality described on this reference page is aligned with the ISO C standard. any conflict between the requirements described here and the ISO C standard is unintentional β no drama intended fr. and this volume of POSIX.1β2017 defers to the ISO C standard. periodt.
okay so the value of status may be 0, EXIT_SUCCESS, EXIT_FAILURE, or literally any other value you want, but β and this is the part everyone forgets β only the least significant 8 bits (that is, status & 0377) shall be available from wait() and waitpid(). the full value shall be available from waitid() and in the siginfo_t passed to a signal handler for SIGCHLD. so if you're passing a big number and wondering why your parent only sees the low byteβ¦ yeah. that's why. π
now the actual sequence, and bestie it is a whole ritual:
The exit() function shall first call all functions registered by atexit(), in the reverse order of their registration β except that a function is called after any previously registered functions that had already been called at the time it was registered. and each function is called as many times as it was registered. so if you registered it twice, she runs twice. no cap.
if, during the call to any such function, a call to the longjmp() function is made that would terminate the call to the registered function, the behavior is undefined. do not do this. i'm serious. π
and if a function registered by a call to atexit() fails to return, the remaining registered functions shall not be called and the rest of the exit() processing shall not be completed. it justβ¦ stops. π
also: if exit() is called more than once, the behavior is undefined. one and done, bestie. don't be greedy.
then β after all that β The exit() function shall flush all open streams with unwritten buffered data and close all open streams. π§ (this is why your output actually shows up, you're welcome)
Finally, the process shall be terminated with the same consequences as described in Consequences of Process Termination. and that's the whole arc. main character exit. β
π RETURN VALUE π
The exit() function does not return. like. she does not come back. there is no "after". it's giving one-way trip. π¦
π ERRORS π
No errors are defined. iconic, honestly β zero problems, zero notes. π
The following sections are informative.
π EXAMPLES π
None. (we're keeping it mysterious β¨)
π§ APPLICATION USAGE π§
None. (see above, the mystery continues π«Ά)
π RATIONALE π
See _Exit(). that's it. that's the whole rationale. she's concise. π
β FUTURE DIRECTIONS β
None. the future is bright and also empty. π
π₯ SEE ALSO π₯
_Exit()atexit()execlongjmp()tmpfile()wait()waitid()
and also: The Base Definitions volume of POSIX.1β2017, <stdlib.h>. go read those, bestie, i'll wait. π
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, gorgeous π«Ά this one came from IEEE/The Open Group, 2017 β so like, credit where credit's due, she's an elder icon at this point. go forth and exit(EXIT_SUCCESS), you've earned it. π
β¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms