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