Reclaim process user space resource exit () function _ exit () function atexit () function on_exit () function, _ exitatexitAbstract:This article describes how to terminate a process and how to use the exit () function to terminate the process and
Abstract:This article describes how to terminate a process and how to use the exit () function to terminate the process and reclaim the user space resources of the process. It analyzes the exit () function and the _ exit () function, difference in
The use of the Exit function in C languageExit () End the current process/current program/, in the entire program, as long as the exit is called, the endReturn () is the current function return, of course, if it is in the main function main, it will
Linux C language exit function explanation
The C standard defines the following exit functions: # Include void exit (INT status); void _ exit (INT status); int atexit (void (* function) (void); function introduction: void exit (INT status) The
C language _exit () function: End Process Executionheader file:
#include
To define a function:
void _exit (int status);
Function Description: _exit () is used to immediately end the execution of the current process,
Exit () End the current process/current program/, in the entire program, as long as the exit is called, the endReturn () is the current function return, of course, if it is in the main function main, it will naturally end the current process, if not,
The exit and _ exit functions are used to terminate a program normally: _ Exit immediately enters the kernel, and exit is used to execute some cleanup operations (including calling and executing various termination processes, close all standard I/O
Exit () ends the current process/current program/. In the whole program, it ends when exit is called.
Return () is the return of the current function. Of course, if it is in the main function, the current process is naturally ended. If it is not, it
Differences between exit () and _ exit ()
Linux source code
# DEFINE _ nr_exit 1
# DEFINE _ nR _ exit _ nr_exit/* from the File Include/asm-i386/unistd. H */"_ NR _" is the prefix for each system call in the Linux source code. Note that there are
The difference between Exit function exits () and return function returns () in program code
Exit (0): run The program normally and exit the program;
Exit (1): Abnormal operation results in exiting the program;
Return (): Returns a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.