1_exit(2)                      System Calls Manual                     _exit(2)
2
3
4

NAME

6       _exit, _Exit - terminate the calling process
7

LIBRARY

9       Standard C library (libc, -lc)
10

SYNOPSIS

12       #include <unistd.h>
13
14       [[noreturn]] void _exit(int status);
15
16       #include <stdlib.h>
17
18       [[noreturn]] void _Exit(int status);
19
20   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
21
22       _Exit():
23           _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L
24

DESCRIPTION

26       _exit()  terminates  the  calling process "immediately".  Any open file
27       descriptors belonging to the process are closed.  Any children  of  the
28       process are inherited by init(1) (or by the nearest "subreaper" process
29       as defined through the use of the prctl(2) PR_SET_CHILD_SUBREAPER oper‐
30       ation).  The process's parent is sent a SIGCHLD signal.
31
32       The  value  status  &  0xFF  is  returned  to the parent process as the
33       process's exit status, and can be collected by the parent using one  of
34       the wait(2) family of calls.
35
36       The function _Exit() is equivalent to _exit().
37

RETURN VALUE

39       These functions do not return.
40

STANDARDS

42       _exit()
43              POSIX.1-2008.
44
45       _Exit()
46              C11, POSIX.1-2008.
47

HISTORY

49       POSIX.1-2001, SVr4, 4.3BSD.
50
51       _Exit() was introduced by C99.
52

NOTES

54       For  a  discussion  on the effects of an exit, the transmission of exit
55       status, zombie processes, signals sent, and so on, see exit(3).
56
57       The function _exit() is like exit(3), but does not call  any  functions
58       registered with atexit(3) or on_exit(3).  Open stdio(3) streams are not
59       flushed.  On the other hand, _exit() does close open file  descriptors,
60       and this may cause an unknown delay, waiting for pending output to fin‐
61       ish.  If the delay is undesired, it may be  useful  to  call  functions
62       like  tcflush(3)  before  calling  _exit().  Whether any pending I/O is
63       canceled, and which pending I/O may be canceled upon _exit(), is imple‐
64       mentation-dependent.
65
66   C library/kernel differences
67       The  text  above  in  DESCRIPTION  describes  the traditional effect of
68       _exit(), which is to terminate a process, and these are  the  semantics
69       specified by POSIX.1 and implemented by the C library wrapper function.
70       On modern systems,  this  means  termination  of  all  threads  in  the
71       process.
72
73       By  contrast with the C library wrapper function, the raw Linux _exit()
74       system call terminates only the calling thread, and actions such as re‐
75       parenting  child processes or sending SIGCHLD to the parent process are
76       performed only if this is the last thread in the thread group.
77
78       Up to glibc 2.3, the _exit() wrapper function invoked the kernel system
79       call  of  the same name.  Since glibc 2.3, the wrapper function invokes
80       exit_group(2), in order to terminate all of the threads in a process.
81

SEE ALSO

83       execve(2), exit_group(2), fork(2), kill(2),  wait(2),  wait4(2),  wait‐
84       pid(2), atexit(3), exit(3), on_exit(3), termios(3)
85
86
87
88Linux man-pages 6.05              2023-03-30                          _exit(2)
Impressum