- 论坛徽章:
- 0
|
回复 12# 一介村夫
exit会做额外的清理工作,比如说会刷新缓冲区,在执行atexit/on_exit时会先注册在执行。
The exit() function causes normal process termination and the
value of status & 0377 is returned to the parent (see wait(2)).
All functions registered with atexit(3) and on_exit(3) are
called, in the reverse order of their registration. (It is
possible for one of these functions to use atexit(3) or
on_exit(3) to register an additional function to be executed
during exit processing; the new registration is added to the
front of the list of functions that remain to be called.) If
one of these functions does not return (e.g., it calls
_exit(2), or kills itself with a signal), then none of the
remaining functions is called, and further exit processing (in
particular, flushing of stdio(3) streams) is abandoned. If a
function has been registered multiple times using atexit(3) or
on_exit(3), then it is called as many times as it was regis-
tered.
|
|