exit(2)
Name
_exit − terminate a process
Syntax
#include <stdlib.h>
void _exit(status)
int status;
Description
The function, _exit, terminates a 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 of status are made available to it. For further information, see wait(.).
•The parent process ID of all of the calling process’s existing child processes and zombie processes are also set to 1. This means that the initialization process inherits each of these processes as well. For further information, see intro(,),
•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(,), ) 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.
•An accounting record is written on the accounting file if the system’s accounting routine is enabled. For more information, see acct(.).
Calling _exit directly circumvents all cleanup. Most C programs call the library routine exit(,), which performs cleanup actions in the standard I/O library before calling _exit.
Environment
POSIX, System V
The _exit function differs from the System V as well as POSIX definition in that even if the calling process is a process group leader, the SIGHUP signal is not sent to each process that has a process group ID equal to that of the calling process.
The _exit function also differs in that the exit routine is declared as type int instead of type void.