Home Explore Blog CI



man-pages

1st chunk of `exit.man`
25a46d3b862fbd502b7ec215364118204c01037ecd53310700000001000010eb
exit(3)                                                                                             Library Functions Manual                                                                                             exit(3)

NAME
       exit - cause normal process termination

LIBRARY
       Standard C library (libc, -lc)

SYNOPSIS
       #include <stdlib.h>

       [[noreturn]] void exit(int status);

DESCRIPTION
       The exit() function causes normal process termination and the least significant byte of status (i.e., status & 0xFF) is returned to the parent (see wait(2)).

       All functions registered with atexit(3) and on_exit(3) are called, in the reverse order of their registration.  (It is possible for one of these functions to use atexit(3) or on_exit(3) to register an additional func‐
       tion  to be executed during exit processing; the new registration is added to the front of the list of functions that remain to be called.)  If one of these functions does not return (e.g., it calls _exit(2), or kills
       itself with a signal), then none of the remaining functions is called, and further exit processing (in particular, flushing of stdio(3) streams) is abandoned.  If a function has been registered  multiple  times  using
       atexit(3) or on_exit(3), then it is called as many times as it was registered.

       All open stdio(3) streams are flushed and closed.  Files created by tmpfile(3) are removed.

       The C standard specifies two constants, EXIT_SUCCESS and EXIT_FAILURE, that may be passed to exit() to indicate successful or unsuccessful termination, respectively.

RETURN VALUE
       The exit() function does not return.

ATTRIBUTES
       For an explanation of the terms used in this section, see attributes(7).
       ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┬───────────────┬─────────────────────┐
       │ Interface                                                                                                                                                                       │ Attribute     │ Value               │
       ├─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┼───────────────┼─────────────────────┤
       │ exit()                                                                                                                                                                          │ Thread safety │ MT‐Unsafe race:exit │
       └─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┴───────────────┴─────────────────────┘

       The exit() function uses a global variable that is not protected, so it is not thread‐safe.

STANDARDS
 

Title: exit(3) - Normal process termination
Summary
The `exit()` function causes a process to terminate normally. It returns the least significant byte of the status to the parent process. Functions registered with `atexit(3)` and `on_exit(3)` are called in reverse order of registration. Open stdio streams are flushed and closed, and files created by `tmpfile(3)` are removed. The C standard provides `EXIT_SUCCESS` and `EXIT_FAILURE` constants for indicating successful or unsuccessful termination. The `exit()` function is not thread-safe.