Open System Services System Calls Reference Manual (G06.29+, H06.08+, J06.03+)
System Functions (e) _exit(2)
NAME
_exit - Terminates a process
LIBRARY
G-series native Guardian processes: system library
G-series native OSS processes: system library
H-series native Guardian processes: implicit libraries
H-series OSS processes: implicit libraries
SYNOPSIS
#include <unistd.h>
void _exit(
int status);
PARAMETERS
status Indicates the status of the process.
DESCRIPTION
The _exit() function terminates the calling process and causes the following to occur:
• All the file descriptors and directory streams that are open in the calling process are
closed.
• All shared memory segments attached to the calling process are detached from it. The
value of the shm_nattch field in the data structure associated with the shared memory
identifier of each affected shared memory segment is decremented by 1. Refer to the
shmget(2) reference page for more information.
• The semadj value established by the calling process for each semaphore is added to the
semval value for that semaphore. Refer to the semop(2) reference page for more infor-
mation.
• Terminating a process by exiting does not terminate its child processes. Instead, the
parent process ID of all the calling process’s child processes and zombie child processes
is set to 1.
• If the parent process of the calling process is executing the wait() or waitpid( ) function,
the parent is notified of the termination of the calling process and the low-order 8 bits
(that is, bits 24 through 31) of the status parameter are made available to it.
• If the parent process is not executing the wait() or waitpid( ) function when the child
process terminates, the parent can do so later and the child’s status will be returned to it
at that time. Meanwhile, the child process is transformed into a zombie process, and its
parent process is sent a SIGCHLD signal to notify it of the termination of a child pro-
cess.
A zombie process is a process that occupies a slot in the process table but has no other
space allocated to it either in user or kernel space. The process table slot that it occupies
is partially overlaid with time-accounting information to be used by the times( ) function.
(See the sys/proc.h header file.)
A process remains a zombie process until its parent process issues a call to the wait() or
waitpid() function. At this time, the zombie process goes away and its process table
entry is released.
• If the process is a controlling process, a SIGHUP signal is sent to each process in the
foreground process group of the controlling terminal belonging to the calling process.
The controlling terminal is dissociated from the session, allowing it to be acquired by a
527186-023 Hewlett-Packard Company 2−51