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