120023Smckusick.\" Copyright (c) 1980 Regents of the University of California. 247208Scael.\" All rights reserved. 320023Smckusick.\" 447208Scael.\" %sccs.include.redist.man% 520023Smckusick.\" 6*58471Smckusick.\" @(#)_exit.2 6.8 (Berkeley) 03/04/93 747208Scael.\" 850541Scael.Dd 9*58471Smckusick.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> 16*58471Smckusick.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 32*58471Smckusickor catches the 3347208Scael.Dv SIGCHLD 3447208Scaelsignal, 3547208Scaelit is notified of the calling process's termination and 3647208Scaelthe 3747208Scael.Em status 38*58471Smckusickis 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. 46*58471Smckusick.It 47*58471SmckusickIf the termination of the process causes any process group 48*58471Smckusickto become orphaned (usually because the parents of all members 49*58471Smckusickof the group have now exited; see 50*58471Smckusick.Dq orphaned process group 51*58471Smckusickin 52*58471Smckusick.Xr intro 2 ) , 53*58471Smckusickand if any member of the orphaned group is stopped, 54*58471Smckusickthe 55*58471Smckusick.Dv SIGHUP 56*58471Smckusicksignal and the 57*58471Smckusick.Dv SIGCONT 58*58471Smckusicksignal are sent to all members of the newly-orphaned process group. 59*58471Smckusick.It 60*58471SmckusickIf the process is a controlling process (see 61*58471Smckusick.Xr intro 2 ) , 62*58471Smckusickthe 63*58471Smckusick.Dv SIGHUP 64*58471Smckusicksignal is sent to the foreground process group of the controlling terminal, 65*58471Smckusickand 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 82*58471Smckusick.Sh STANDARDS 83*58471SmckusickThe 84*58471Smckusick.Nm _exit 85*58471Smckusickfunction is defined by 86*58471Smckusick.St -p1003.1-88 . 87