The C++exit() function cannot end the process

exit() _exit() difference:
_exit() function: directly stop the process, clear the memory space it uses, and destroy its various data structures in the kernel; the
exit() function makes some Packaging, adding several processes before executing the exit.

The biggest difference between the exit() function and the _exit() function is that the exit() function checks the opening of the file before calling the exit system call, and writes the contents of the file buffer back to the file.

If the program uses exit() to end the process, the I/O cache will be cleaned up before the end, and it will not end immediately.

If the program writes a function that handles the signal signal, it may cause the signal to be captured and the process cannot be terminated, and the program enters a state that cannot be terminated, and the stack information is always printed.

 

If the program uses _exit() to end the process, the I/O cache cleanup will not be performed, and it will end. Solve the above problems. But the _exit() function closes the process directly, and the data in the buffer will be lost.

exit() _exit()_LevinLin's Blog-CSDN Blog_exit

Guess you like

Origin blog.csdn.net/Lemon_D1999/article/details/128870230