EXIT(2) — HP-UX
NAME
exit, _exit − terminate process
SYNOPSIS
void exit (status)
int status; void _exit (status)
int status;
DESCRIPTION
Exit terminates the calling process and passes exit’s argument to the system for inspection, see wait(2). Returning from main in a C program has the same effect as exit; the exit value is the function value returned by main. (This value will be undefined if main does not take care to return a value or explicitly call exit.)
Exit is equivalent to _exit, except that exit flushes stdio buffers, while _exit does not. Both exit and _exit terminate the calling process with the following consequences:
All of the file descriptors open in the calling process are closed.
If the parent process of the calling process is executing a wait, it is 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, and does not have SIGCLD set to SIG_IGN, 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. Time accounting information is recorded for use by times(2).
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 (proc1) 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, 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).
If the process ID, tty group ID, and process group ID of the calling process are equal, the SIGHUP signal is sent to each process that has a process group ID equal to that of the calling process. If the process ID and process group ID of the calling process are equal, the process group ID is removed from all processes that belong to the process group of the calling process. However, if the calling process has previously called setpgrp2(2) without subsequently calling setpgrp(2), the SIGHUP signal will not be sent and process groups will be left unaltered.
If the calling process caused a controlling terminal to be allocated (caused the tty group ID for the terminal to be defined), the controlling terminal is now deallocated and all processes that share this terminal as a controlling terminal have their process group ID removed.
If the current process has any child processes that are being traced, they will be sent a SIGKILL signal. If it has other child processes that are stopped, they will be sent SIGHUP and SIGCONT signals.
HARDWARE DEPENDENCIES
Series 200, 300, 500
Job control is not supported.
AUTHOR
Exit was developed by HP, AT&T, and the University of California, Berkeley.
SEE ALSO
Exit conditions ($?) in sh(1), acct(2), plock(2), semop(2), shmop(2), signal(2), times(2), vfork(2), wait(2).
Hewlett-Packard Company — Version B.1, May 11, 2021