xref: /dragonfly/lib/libc/sys/_exit.2 (revision b40e316c)
1.\" Copyright (c) 1980, 1993
2.\"	The Regents of the University of California.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by the University of
15.\"	California, Berkeley and its contributors.
16.\" 4. Neither the name of the University nor the names of its contributors
17.\"    may be used to endorse or promote products derived from this software
18.\"    without specific prior written permission.
19.\"
20.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
21.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
24.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
25.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
26.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
27.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
29.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
30.\" SUCH DAMAGE.
31.\"
32.\"     @(#)_exit.2	8.1 (Berkeley) 6/4/93
33.\" $FreeBSD: src/lib/libc/sys/_exit.2,v 1.10.2.4 2001/12/14 18:34:00 ru Exp $
34.\" $DragonFly: src/lib/libc/sys/_exit.2,v 1.2 2003/06/17 04:26:47 dillon Exp $
35.\"
36.Dd June 4, 1993
37.Dt EXIT 2
38.Os
39.Sh NAME
40.Nm _exit
41.Nd terminate the calling process
42.Sh LIBRARY
43.Lb libc
44.Sh SYNOPSIS
45.In unistd.h
46.Ft void
47.Fn _exit "int status"
48.Sh DESCRIPTION
49The
50.Fn _exit
51function
52terminates a process with the following consequences:
53.Bl -bullet
54.It
55All of the descriptors open in the calling process are closed.
56This may entail delays, for example, waiting for output to drain;
57a process in this state may not be killed, as it is already dying.
58.It
59If the parent process of the calling process has an outstanding
60.Xr wait 2
61call
62or catches the
63.Dv SIGCHLD
64signal,
65it is notified of the calling process's termination and
66the
67.Em status
68is set as defined by
69.Xr wait 2 .
70.It
71The parent process-ID of all of the calling process's existing child
72processes are set to 1; the initialization process
73(see the
74.Sx DEFINITIONS
75section of
76.Xr intro 2 )
77inherits each of these processes.
78.It
79If the termination of the process causes any process group
80to become orphaned (usually because the parents of all members
81of the group have now exited; see
82.Dq orphaned process group
83in
84.Xr intro 2 ) ,
85and if any member of the orphaned group is stopped,
86the
87.Dv SIGHUP
88signal and the
89.Dv SIGCONT
90signal are sent to all members of the newly-orphaned process group.
91.It
92If the process is a controlling process (see
93.Xr intro 2 ) ,
94the
95.Dv SIGHUP
96signal is sent to the foreground process group of the controlling terminal,
97and all current access to the controlling terminal is revoked.
98.El
99.Pp
100Most C programs call the library routine
101.Xr exit 3 ,
102which flushes buffers, closes streams, unlinks temporary files, etc.,
103before
104calling
105.Fn _exit .
106.Sh RETURN VALUES
107.Fn _exit
108can never return.
109.Sh SEE ALSO
110.Xr fork 2 ,
111.Xr sigaction 2 ,
112.Xr wait 2 ,
113.Xr exit 3
114.Sh STANDARDS
115The
116.Fn _exit
117function call is expected to conform to
118.St -p1003.1-90 .
119.Sh HISTORY
120An
121.Fn _exit
122function call appeared in
123.At v7 .
124