SYNOPSIS
#include <stdlib.h> void exit(int status); |
DESCRIPTION
부모 프로세스는 wait(2)를 이용해서 자식 프로세스의 종료값을 읽어 올수 있다.
exit()가 호출되면 atexit(3)와 on_exit(3)에 의해서 등록된 함수들이 먼저 실행된다.
그 후 모든 열린 스트림을 비우고(flush)닫는다. tmpfile(3)에 의해서 생성된 임시파일도 이때 삭제된다.
표준 C에서는 exit()의 종료값을 위해서 EXIT_SUCCESS 와 EXIT_FAILURE를 준비해두고 있다.
RETURN VALUE
exit() 함수는 아무것도 리턴하지 않는다.
CONFORMING TO
SVr4, 4.3BSD, POSIX.1-2001, C89, C99.
NOTES
It is undefined what happens if one of the functions registered using
atexit(3) and on_exit(3) calls either exit() or longjmp(3).
The use of EXIT_SUCCESS and EXIT_FAILURE is slightly more portable (to
non-Unix environments) than the use of 0 and some nonzero value like 1
or -1. In particular, VMS uses a different convention.
BSD has attempted to standardize exit codes; see the file <sysexits.h>.
After exit(), the exit status must be transmitted to the parent pro-
cess. There are three cases. If the parent has set SA_NOCLDWAIT, or
has set the SIGCHLD handler to SIG_IGN, the status is discarded. If
the parent was waiting on the child it is notified of the exit status.
In both cases the exiting process dies immediately. If the parent has
not indicated that it is not interested in the exit status, but is not
waiting, the exiting process turns into a "zombie" process (which is
nothing but a container for the single byte representing the exit sta-
tus) so that the parent can learn the exit status when it later calls
one of the wait(2) functions.
If the implementation supports the SIGCHLD signal, this signal is sent
to the parent. If the parent has set SA_NOCLDWAIT, it is undefined
whether a SIGCHLD signal is sent.
If the process is a session leader and its controlling terminal is the
controlling terminal of the session, then each process in the fore-
ground process group of this controlling terminal is sent a SIGHUP sig-
nal, and the terminal is disassociated from this session, allowing it
to be acquired by a new controlling process.
If the exit of the process causes a process group to become orphaned,
and if any member of the newly orphaned process group is stopped, then
a SIGHUP signal followed by a SIGCONT signal will be sent to each pro-
cess in this process group.
SEE ALSO
_exit(2), wait(2), atexit(3), on_exit(3), tmpfile(3)
'API 및 라이브러리 > C 라이브러리 함수' 카테고리의 다른 글
malloc(3) (0) | 2009.03.31 |
---|---|
strcpy(3) (0) | 2009.03.31 |
getenv(3) (1) | 2009.03.30 |
fclose(3) (0) | 2009.03.29 |
getopt(3) (0) | 2009.03.28 |