In C, exit() terminates the calling process without executing the rest code which is after the exit() function.
Now the question is that if we have exit() function then why C11 standard introduced _Exit()? Actually exit() function performs some cleaning before termination of the program like connection termination, buffer flushes etc. The _Exit() function in C/C++ gives normal termination of a program without performing any cleanup tasks. For example it does not execute functions registered with atexit.
// Here the exit_code represent the exit status // of the program which can be 0 or non-zero. // The _Exit() function returns nothing. void _Exit(int exit_code);
Showing difference through programs:
If we replace exit with _Exit(), then nothing is printed.
This article is contributed by Bishal Kumar Dubey. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
- exit(), abort() and assert()
- return statement vs exit() in main()
- Exit status of a child process in Linux
- asctime() and asctime_s() functions in C with Examples
- time.h header file in C with Examples
- C++ program to compare two Strings using Operator Overloading
- not1 and not2 function templates in C++ STL with Examples
- Go vs C++
- Trie Data Structure using smart pointer and OOP in C++
- std::hash class in C++ STL
- History of C++
- What are Forward declarations in C++
- __builtin_inf() functions of GCC compiler
- Structures in C++
Improved By : Vishal Vishwakarma