- 论坛徽章:
- 0
|
_exit和exit的区别? (无内容)
From POSIX programmers' guide
Calling exit()
The exit() function causes normal program termination. The EXIT_SUCCESS macro can
be used to indicate successful termination. Since the POSIX standard requires that
EXIT_SUCCESS be defined as zero, it is safe to write exit(0), keeping with historical
practice. The call exit(0) is extremely portable.
The exit() function performs the following functions:
1. All functions registered by the Standard C atexit() function are called in the reverse
order of registration. If any of these functions calls exit(), the results are not portable.
2. All open output streams are flushed (data written out) and the streams are closed.
3. All files created by tmpfile() are deleted.
4. The _exit() function is called.
Calling _exit()
The _exit() function performs operating system-specific program termination functions.
These include:
1. All open file descriptors and directory streams are closed.
2. If the parent process is executing a wait() or waitpid(), the parent wakes up and
status is made available.
3. If the parent is not executing a wait() or waitpid(), the status is saved for return to
the parent on a subsequent wait() or waitpid().
4. Children of the terminated process are assigned a new parent process ID. Note: the
termination of a parent does not directly terminate its children.
5. If the implementation supports the SIGCHLD signal, a SIGCHLD is sent to the parent.
6. Several job control signals are sent. |
|