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
- Minimum cells to be flipped to get a 2*2 submatrix with equal elements
- Nested Loops in C++ with Examples
- Slack Bytes in Structures : Explained with Example
- _Find_first() function in C++ bitset with Examples
- _Find_next() function in C++ bitset with Examples
- Left-Right traversal of all the levels of N-ary tree
- Difference between Iterators and Pointers in C/C++ with Examples
- ostream::seekp(pos) method in C++ with Exmaples
- Default Methods in C++ with Examples
- C program to count number of vowels and consonants in a String
- Nested Loops in C with Examples
Improved By : Vishal Vishwakarma