exit(S)
exit, _exit, _Exit --
terminate process
Synopsis
#include <stdlib.h>
void exit(int status);
#include <unistd.h>
void _exit(int status);
#include <unistd.h>
void _Exit(int status);
Description
_exit and _Exit terminate the calling process
with the following consequences:
-
All of the file descriptors, directory streams and message catalogue
descriptors open in the calling process are closed.
-
A SIGCHLD signal is sent to the calling process's parent process.
-
If the parent process of the calling process has not specified the
SA_NOCLDWAIT flag [see
sigaction(S)],
the calling process is transformed into a ``zombie process.''
A zombie process is a process that only occupies an entry in the process list.
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 <sys/proc.h>]
to be used by the times system call.
-
The parent process
ID
of all of the calling process's existing child processes and zombie
processes is set to 1.
This means the initialization process [see
intro(S)]
inherits each of these processes.
-
Each attached shared memory segment is detached and the value of
shm_nattach in the data structure associated with its shared memory
identifier is decremented by 1.
-
For each semaphore for which the calling process has set a semadj value
[see
semop(S)],
that semadj value is added to the semval
of the specified semaphore.
-
If the process has a process, text, or data lock, an unlock is performed
[see
plock(S)].
-
An accounting record is written on the accounting file if the system's
accounting routine is enabled [see
acct(S)].
-
If the process is a controlling process, SIGHUP
is sent to the foreground process group of its controlling terminal and
its controlling terminal is deallocated.
-
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 SIGHUP
and SIGCONT signals.
The C function exit calls any functions registered through the
atexit function in the reverse order of their registration.
The _exit and _Exit functions circumvent all such
functions and cleanup. (Note also that if a process receives a signal
that has an action of Exit or Core, the functions registered with
atexit are not called.
See
signal(M).)
The symbols EXIT_SUCCESS and EXIT_FAILURE are defined in
stdlib.h and may be used as the value of status to indicate
successful or unsuccessful termination, respectively.
The low-order 8 bits of status is available through
wait(S)
(and similar functions).
References
_lwp_exit(S),
acct(S),
atexit(S)
intro(S),
plock(S),
semop(S),
sigaction(S),
signal(S),
times(S),
wait(S).
Notices
Considerations for threads programming
The _exit and _Exit system calls terminate the
containing process. This implies the termination of all threads.
Considerations for lightweight processes
The termination of the process also implies the termination of all
LWPs contained by that process.
© 2005 The SCO Group, Inc. All rights reserved.
SCO OpenServer Release 6.0.0 - 01 June 2005