]>
Commit | Line | Data |
---|---|---|
fea681da | 1 | .\" This manpage is Copyright (C) 1992 Drew Eckhardt; |
ac56b6a8 | 2 | .\" and Copyright (C) 1993 Michael Haardt, Ian Jackson. |
fea681da | 3 | .\" |
5fbde956 | 4 | .\" SPDX-License-Identifier: Linux-man-pages-copyleft |
fea681da MK |
5 | .\" |
6 | .\" Modified Wed Jul 21 23:02:38 1993 by Rik Faith <faith@cs.unc.edu> | |
7 | .\" Modified 2001-11-17, aeb | |
8 | .\" | |
1d767b55 | 9 | .TH _EXIT 2 2021-03-22 "Linux" "Linux Programmer's Manual" |
fea681da | 10 | .SH NAME |
a1ffe9f5 | 11 | _exit, _Exit \- terminate the calling process |
edf2e4a8 AC |
12 | .SH LIBRARY |
13 | Standard C library | |
8fc3b2cf | 14 | .RI ( libc ", " \-lc ) |
fea681da | 15 | .SH SYNOPSIS |
c7db92b9 | 16 | .nf |
fea681da | 17 | .B #include <unistd.h> |
68e4db0a | 18 | .PP |
d8a9e2bb | 19 | .BI "noreturn void _exit(int " status ); |
eaa18d3c | 20 | .PP |
fea681da | 21 | .B #include <stdlib.h> |
68e4db0a | 22 | .PP |
d8a9e2bb | 23 | .BI "noreturn void _Exit(int " status ); |
c7db92b9 | 24 | .fi |
68e4db0a | 25 | .PP |
d39ad78f | 26 | .RS -4 |
cc4615cc MK |
27 | Feature Test Macro Requirements for glibc (see |
28 | .BR feature_test_macros (7)): | |
d39ad78f | 29 | .RE |
68e4db0a | 30 | .PP |
cc4615cc | 31 | .BR _Exit (): |
9d2adbae | 32 | .nf |
5c10d2c5 | 33 | _ISOC99_SOURCE || _POSIX_C_SOURCE >= 200112L |
9d2adbae | 34 | .fi |
fea681da | 35 | .SH DESCRIPTION |
63aa9df0 | 36 | .BR _exit () |
c13182ef | 37 | terminates the calling process "immediately". |
55873ed6 | 38 | Any open file descriptors belonging to the process are closed. |
99ed723a | 39 | Any children of the process are inherited by |
a88f0e06 | 40 | .BR init (1) |
99ed723a MK |
41 | (or by the nearest "subreaper" process as defined through the use of the |
42 | .BR prctl (2) | |
43 | .B PR_SET_CHILD_SUBREAPER | |
44 | operation). | |
55873ed6 | 45 | The process's parent is sent a |
fea681da MK |
46 | .B SIGCHLD |
47 | signal. | |
dd3568a1 | 48 | .PP |
fea681da | 49 | The value |
f3491e47 | 50 | .I "status & 0xFF" |
fea681da | 51 | is returned to the parent process as the process's exit status, and |
07f462e9 | 52 | can be collected by the parent using one of the |
0bfa087b | 53 | .BR wait (2) |
fea681da | 54 | family of calls. |
dd3568a1 | 55 | .PP |
fea681da | 56 | The function |
63aa9df0 | 57 | .BR _Exit () |
fea681da | 58 | is equivalent to |
63aa9df0 | 59 | .BR _exit (). |
47297adb | 60 | .SH RETURN VALUE |
fea681da | 61 | These functions do not return. |
47297adb | 62 | .SH CONFORMING TO |
5a3b5c1d | 63 | POSIX.1-2001, POSIX.1-2008, SVr4, 4.3BSD. |
60a90ecd MK |
64 | The function |
65 | .BR _Exit () | |
66 | was introduced by C99. | |
fea681da MK |
67 | .SH NOTES |
68 | For a discussion on the effects of an exit, the transmission of | |
078a7d6e | 69 | exit status, zombie processes, signals sent, and so on, see |
fea681da | 70 | .BR exit (3). |
dd3568a1 | 71 | .PP |
fea681da | 72 | The function |
63aa9df0 | 73 | .BR _exit () |
60a90ecd MK |
74 | is like |
75 | .BR exit (3), | |
76 | but does not call any | |
7b57506d | 77 | functions registered with |
0bfa087b | 78 | .BR atexit (3) |
c13182ef | 79 | or |
0bfa087b | 80 | .BR on_exit (3). |
29c4533c MK |
81 | Open |
82 | .BR stdio (3) | |
83 | streams are not flushed. | |
fea681da | 84 | On the other hand, |
63aa9df0 | 85 | .BR _exit () |
fea681da | 86 | does close open file descriptors, and this may cause an unknown delay, |
c13182ef MK |
87 | waiting for pending output to finish. |
88 | If the delay is undesired, | |
988db661 | 89 | it may be useful to call functions like |
0bfa087b | 90 | .BR tcflush (3) |
60a90ecd MK |
91 | before calling |
92 | .BR _exit (). | |
d9bfdb9c MK |
93 | Whether any pending I/O is canceled, and which pending I/O may be |
94 | canceled upon | |
60a90ecd MK |
95 | .BR _exit (), |
96 | is implementation-dependent. | |
0722a578 | 97 | .SS C library/kernel differences |
d99b5be0 MK |
98 | The text above in DESCRIPTION describes the traditional effect of |
99 | .BR _exit (), | |
100 | which is to terminate a process, | |
101 | and these are the semantics specified by POSIIX.1 and implemented | |
102 | by the C library wrapper function. | |
103 | On modern systems, this means termination of all threads in the process. | |
737a840d | 104 | .PP |
d99b5be0 | 105 | By contrast with the C library wrapper function, the raw Linux |
cd356fa1 | 106 | .BR _exit () |
737a840d MK |
107 | system call terminates only the calling thread, and actions such as |
108 | reparenting child processes or sending | |
109 | .B SIGCHLD | |
110 | to the parent process are performed only if this is | |
111 | the last thread in the thread group. | |
112 | .\" _exit() is used by pthread_exit() to terminate the calling thread | |
d99b5be0 MK |
113 | .PP |
114 | In glibc up to version 2.3, the | |
115 | .BR _exit () | |
116 | wrapper function invoked the kernel system call of the same name. | |
117 | Since glibc 2.3, the wrapper function invokes | |
118 | .BR exit_group (2), | |
119 | in order to terminate all of the threads in a process. | |
47297adb | 120 | .SH SEE ALSO |
fea681da | 121 | .BR execve (2), |
f02720dd | 122 | .BR exit_group (2), |
fea681da MK |
123 | .BR fork (2), |
124 | .BR kill (2), | |
125 | .BR wait (2), | |
126 | .BR wait4 (2), | |
127 | .BR waitpid (2), | |
7b57506d | 128 | .BR atexit (3), |
fea681da | 129 | .BR exit (3), |
7b57506d | 130 | .BR on_exit (3), |
fea681da | 131 | .BR termios (3) |