EXIT(3) BSD EXIT(3)
NAME
exit - terminate a process after flushing any pending output
SYNOPSIS
#include <stdlib.h>
int atexit(void (*func)(void))
void exit(status)
int status;
DESCRIPTION
atexit registers the function pointed to by func, to be called without
arguments at normal program termination.
exit causes normal program termination to occur. The following actions
result:
o All functions registered by the atexit function are called, in the
reverse order of their registration.
o All open output streams are flushed, all open file descriptors are
closed, and all files created by tmpfile are removed.
o If the parent process of the calling process is executing a wait, or
is interested in the SIGCHLD signal, it is notified of the calling
process' termination and the low order eight bits of status are made
available to it (see wait(2)).
o The parent process ID of all of the calling processes' existing child
processes is set to 1. This means the initialization process (see
intro(2)) inherits each of these processes.
o Any stopped children are restarted with a hangup signal (SIGHUP).
o A death of child signal (SIGCLD) is sent to the parent.
o An accounting record is written on the accounting file if the system's
accounting routine is enabled (see acct(2)).
SEE ALSO
exit(2), intro(3)
DIAGNOSTICS
atexit returns zero if the registration succeeds, nonzero if it fails.
exit never returns.