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 email@example.com. 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
- Dividing a Large file into Separate Modules in C/C++, Java and Python
- How to delete a range of values from the List using Iterator
- How to create a List with Constructor in C++ STL
- C program to store Student records as Structures and Sort them by Name
- How to delete last element from a List in C++ STL
- Can C++ reference member be declared without being initialized with declaration?
- Finding Floor and Ceil of a Sorted Array using C++ STL
- Some useful C++ tricks for beginners in Competitive Programming
- Replace each node with its Surpasser Count in Linked List
- Comparison of Java with other programming languages
- Print multiples of Unit Digit of Given Number
Improved By : Vishal Vishwakarma