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