HP-UX Reference (11i v1 00/12) - 2 System Calls (vol 5)
__________________________________________________________________________________________________________________________________________________________________________________________________
__________________________________________________________________________________________________________________________________________________________________________________________________
STANDARD Printed by: Nora Chuang [nchuang] STANDARD
/build/1111/BRICK/man2/!!!intro.2
________________________________________________________________
___ ___
e
exit(2) exit(2)
NAME
exit, _exit - terminate process
SYNOPSIS
#include <stdlib.h>
void exit(int status);
#include <unistd.h>
void _exit(int status);
DESCRIPTION
exit() terminates the calling process and passes status to the system for inspection, see wait(2). Return-
ing from main in a C program has the same effect as exit(); the status value is the function value
returned by main (this value is undefined if main does not take care to return a value or to call exit()
explicitly).
If the calling process is multithreaded, all threads/lightweight process in the process will be terminated.
exit() cannot return to its caller. The result of an
exit() call during exit processing is undefined.
The functions
exit() and _exit(), are equivalent, except that
exit() calls functions registered by
atexit() and flushes standard I/O buffers, while _exit() does not. Both exit() and _exit() ter-
minate the calling process with the following consequences. The exact order of these consequences is
unspecified.
Functions registered by
atexit() (see atexit(2)) are called in reverse order of registration.
All file descriptors open in the calling process are closed.
All files created by
tmpfile() are removed (see tmpfile(3S)).
If the parent process of the calling process is executing a wait(), wait3(),orwaitpid(),itis
notified of the calling process’s termination, and the low-order eight bits; i.e., bits 0377 of status are
made available to it (see wait(2)).
If the parent process of the calling process is not executing a
wait(), wait3(),orwaitpid()
,
and does not have
SIGCLD set to SIG_IGN, the calling process is transformed into a zombie pro-
cess.Azombie 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. Time accounting information is recorded for use by
times() (see times(2)).
The parent process ID is set to 1 for all of the calling process’s existing child processes and zombie
processes. This means the initialization process (proc1) inherits each of these processes.
Threads/LWPs terminated by a call to exit()
shall not invoke their cancellation cleanup handlers or
their thread specific data destructor functions.
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 (see shmop(2)).
For each semaphore for which the calling process has set a semadj value (see semop(2)), 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(2).
An accounting record is written on the accounting file if the system’s accounting routine is enabled
(see acct(2)).
A
SIGCHLD signal is sent to the parent process.
If the calling process is a controlling process, the SIGHUP signal is sent to each process in the fore-
ground process group of the controlling terminal belonging to the calling process. The controlling ter-
minal associated with the session is disassociated from the session, allowing it to be acquired by a new
controlling process.
If the exit of the calling process causes a process group to become orphaned, and if any member of the
newly-orphaned process group is stopped, all processes in the newly-orphaned process group are sent
SIGHUP and SIGCONT signals.
If the current process has any child processes that are being traced, they are sent a SIGKILL
signal.
Section 2−−60 − 1 − HP-UX Release 11i: December 2000
___
___