144 lines
4.6 KiB
Groff
144 lines
4.6 KiB
Groff
'\"macro stdmacro
|
|
.if n .pH g2.exit @(#)exit 40.16 of 1/3/91
|
|
.\" Copyright 1991 UNIX System Laboratories, Inc.
|
|
.\" Copyright 1989, 1990 AT&T
|
|
.nr X
|
|
.if \nX=0 .ds x} exit 2 "" "\&"
|
|
.if \nX=1 .ds x} exit 2 ""
|
|
.if \nX=2 .ds x} exit 2 "" "\&"
|
|
.if \nX=3 .ds x} exit "" "" "\&"
|
|
.TH \*(x}
|
|
.SH NAME
|
|
\f4exit\f1, \f4_exit\f1 \- terminate process
|
|
.Op c p a
|
|
.SH C SYNOPSIS
|
|
\f4#include <stdlib.h>\f1
|
|
.PP
|
|
\f4void exit(int status);\f1
|
|
.PP
|
|
\f4#include <unistd.h>\f1
|
|
.PP
|
|
\f4void _exit(int status);\f1
|
|
.Op
|
|
.Op f
|
|
.SH FORTRAN SYNOPSIS
|
|
\f4integer status\f1
|
|
.br
|
|
\f4call exit (status)\f1
|
|
.Op
|
|
.SH DESCRIPTION
|
|
The C library routine \f4exit\fP, which is discussed at the end of
|
|
this section, invokes the system routine \f4_exit\fP upon
|
|
completion of its own cleanup chores.
|
|
\f4_exit\fP
|
|
terminates the calling process with the following consequences:
|
|
.IP
|
|
All of the file descriptors, directory streams and message catalogue
|
|
descriptors open in the calling process are closed. If the process is sharing
|
|
file descriptors via an \f4sproc\fP, other members of the share group
|
|
do NOT have their file descriptors closed.
|
|
.IP
|
|
A \f4SIGCHLD\fP signal is sent to the calling process's parent process.
|
|
.IP
|
|
If the parent process of the calling process has not specified the
|
|
\f4SA_NOCLDWAIT\fP flag [see \f4sigaction\fP(2)],
|
|
the calling process is transformed into a ``zombie process.''
|
|
A
|
|
zombie process
|
|
is a process that only occupies a slot in the process table.
|
|
It has no other space allocated either in user or kernel space.
|
|
The process table slot that it occupies is partially overlaid with
|
|
time accounting information
|
|
[see
|
|
\f4<sys/proc.h>\fP]
|
|
to be used by the
|
|
\f4times\fP system call.
|
|
.IP
|
|
The parent process
|
|
.SM ID
|
|
of all of the calling process's existing
|
|
child processes and zombie processes is set to 1.
|
|
This means the initialization process [see
|
|
\f4intro\fP(2)]
|
|
inherits each of these processes.
|
|
.IP
|
|
If the process belongs to a share group, it is removed from
|
|
that group. Its stack segment is deallocated and removed
|
|
from the share group's virtual space. All other virtual
|
|
space that was shared with the share group is left
|
|
untouched. If the
|
|
.I prctl
|
|
(\f4PR_SETEXITSIG\fP) option has been
|
|
enabled for the share group, than the specified signal is
|
|
sent to all remaining share group members.
|
|
.IP
|
|
Each attached shared memory segment is detached and the value of
|
|
\f4shm_nattach\f1
|
|
in the data structure associated with its shared memory identifier
|
|
is decremented by 1.
|
|
.IP
|
|
For each semaphore for which the calling process has set a \f4semadj\fP value [see
|
|
\f4semop\fP(2)],
|
|
that \f4semadj\fP value is added to the \f4semval\fP of the specified semaphore.
|
|
.IP
|
|
If the process has a process, text, or data lock, an
|
|
.I unlock\^
|
|
is performed [see
|
|
\f4plock\fP(2)].
|
|
If the process has any pages locked, they are unlocked [see \f4mpin\fP(2)].
|
|
.IP
|
|
An accounting record is written on the accounting file if the system's
|
|
accounting routine is enabled [see
|
|
\f4acct\fP(2)].
|
|
.IP
|
|
If the process is a controlling process,
|
|
\f4SIGHUP\f1
|
|
is sent to the foreground process group of its controlling terminal and
|
|
its controlling terminal is deallocated.
|
|
.IP
|
|
If the calling process has any stopped children whose process group
|
|
will be orphaned when the calling process exits, or if the calling
|
|
process is a member of
|
|
a process group that will be orphaned when the calling process exits,
|
|
that process group will be sent
|
|
\f4SIGHUP\f1
|
|
and
|
|
\f4SIGCONT\f1
|
|
signals.
|
|
Note that these signals are not sent if the process became the process group
|
|
leader through the invocation of the \f4setpgrp\fP(2) system call.
|
|
.IP
|
|
In all cases, if the calling process is a process group
|
|
leader and has an associated controlling terminal, the
|
|
controlling terminal is disassociated from the process
|
|
allowing it to be acquired by another process group leader.
|
|
.IP
|
|
Any mapped files are closed and any written pages flushed to
|
|
disk.
|
|
.PP
|
|
The C function
|
|
\f4exit\fP(3C)
|
|
calls any functions registered through the
|
|
\f4atexit\f1 function in the reverse order
|
|
of their registration.
|
|
It then causes each buffered file stream to be flushed, and, unless an
|
|
\f4sproc\fP has been executed, closed.
|
|
The function
|
|
\f4_exit\fP
|
|
circumvents all such functions and cleanup.
|
|
.PP
|
|
The symbols \f4EXIT_SUCCESS\fP and \f4EXIT_FAILURE\fP are defined in
|
|
\f4stdlib.h\fP and may be used as the value of \f2status\fP to indicate
|
|
successful or unsuccessful termination, respectively.
|
|
.SH "SEE ALSO"
|
|
\f4acct\fP(2), \f4intro\fP(2), \f4plock\fP(2),
|
|
\f4semop\fP(2), \f4sigaction\fP(2), \f4signal\fP(2),
|
|
\f4mmap\fP(2), \f4mpin\fP(2), \f4prctl\fP(2), \f4sigprocmask\fP(2),
|
|
\f4sigvec\fP(3B), \f4sigblock\fP(3B), \f4sigsetmask\fP(3B),
|
|
\f4times\fP(2), \f4wait\fP(2), \f4atexit\f1(3C).
|
|
.SH NOTES
|
|
See \f4signal\fP(2)
|
|
\s-1NOTES\s0.
|
|
.\" @(#)exit.2 6.2 of 9/6/83
|
|
.Ee
|