1*61181Sbostic.\" Copyright (c) 1980, 1993 2*61181Sbostic.\" The Regents of the University of California. All rights reserved. 320023Smckusick.\" 447208Scael.\" %sccs.include.redist.man% 520023Smckusick.\" 6*61181Sbostic.\" @(#)_exit.2 8.1 (Berkeley) 06/04/93 747208Scael.\" 850541Scael.Dd 958471Smckusick.Dt EXIT 2 1047208Scael.Os BSD 4 1147208Scael.Sh NAME 1247208Scael.Nm _exit 1347208Scael.Nd terminate the calling process 1447208Scael.Sh SYNOPSIS 1547208Scael.Fd #include <unistd.h> 1658471Smckusick.Ft void 1747208Scael.Fn _exit "int status" 1847208Scael.Sh DESCRIPTION 1947208ScaelThe 2047208Scael.Fn _exit 2147208Scaelfunction 2220024Smckusickterminates a process with the following consequences: 2347208Scael.Bl -bullet 2447208Scael.It 2520024SmckusickAll of the descriptors open in the calling process are closed. 2628365SanneThis may entail delays, for example, waiting for output to drain; 2728069Skarelsa process in this state may not be killed, as it is already dying. 2847208Scael.It 2947208ScaelIf the parent process of the calling process has an outstanding 3047208Scael.Xr wait 3147208Scaelcall 3258471Smckusickor catches the 3347208Scael.Dv SIGCHLD 3447208Scaelsignal, 3547208Scaelit is notified of the calling process's termination and 3647208Scaelthe 3747208Scael.Em status 3858471Smckusickis set as defined by 3947208Scael.Xr wait 2 . 4047208Scael.It 4147208ScaelThe parent process-ID of all of the calling process's existing child 4247208Scaelprocesses are set to 1; the initialization process 4347208Scael(see the DEFINITIONS section of 4447208Scael.Xr intro 2 ) 4547208Scaelinherits each of these processes. 4658471Smckusick.It 4758471SmckusickIf the termination of the process causes any process group 4858471Smckusickto become orphaned (usually because the parents of all members 4958471Smckusickof the group have now exited; see 5058471Smckusick.Dq orphaned process group 5158471Smckusickin 5258471Smckusick.Xr intro 2 ) , 5358471Smckusickand if any member of the orphaned group is stopped, 5458471Smckusickthe 5558471Smckusick.Dv SIGHUP 5658471Smckusicksignal and the 5758471Smckusick.Dv SIGCONT 5858471Smckusicksignal are sent to all members of the newly-orphaned process group. 5958471Smckusick.It 6058471SmckusickIf the process is a controlling process (see 6158471Smckusick.Xr intro 2 ) , 6258471Smckusickthe 6358471Smckusick.Dv SIGHUP 6458471Smckusicksignal is sent to the foreground process group of the controlling terminal, 6558471Smckusickand all current access to the controlling terminal is revoked. 6647208Scael.El 6747208Scael.Pp 6820024SmckusickMost C programs call the library routine 6947208Scael.Xr exit 3 , 7047208Scaelwhich flushes buffers, closes streams, unlinks temporary files, etc., 7147208Scaelbefore 7247208Scaelcalling 7347208Scael.Fn _exit . 7447208Scael.Sh RETURN VALUE 7547208Scael.Fn _exit 7647208Scaelcan never return. 7747208Scael.Sh SEE ALSO 7847208Scael.Xr fork 2 , 7947208Scael.Xr sigvec 2 , 8047208Scael.Xr wait 2 , 8147208Scael.Xr exit 3 8258471Smckusick.Sh STANDARDS 8358471SmckusickThe 8458471Smckusick.Nm _exit 8558471Smckusickfunction is defined by 8658471Smckusick.St -p1003.1-88 . 87