Format
#include <stdlib.h> /* also in <process.h> */ void _exit(int status);
Language Level: Extension
_exit ends the calling process without calling functions
registered by _onexit or atexit. It also does not flush stream
buffers or delete temporary files. You supply the status
value as a parameter; the value 0 typically means a normal exit.
Return Value
Although _exit does not return a value, the value is
available to the waiting parent process, if there is one, after
the child process ends. If no parent process waits for the
exiting process, the status value is lost. The status
value is available through the operating system batch command IF
ERRORLEVEL.
Example
This example calls _exit to end the process. Because
_exit does not flush the buffer first, the output from the second
printf statement will not appear.
#include <stdio.h> /*you can also use <process.h>*/ #include <stdlib.h>
char buf[51];
int main(void)
{
/* Make sure the standard outoyt stream is line-buffered even if the */ /* output is redirected to a file. */
if (0 != setvbuf(stdout, buf, _IOLBF, 50))
printf("The buffering was not set correctly.\n")
printf("This will print out but ...\n");
printf("this will not!");
_exit(EXIT_FAILURE);
return 0;
/**********************************************************************
The output should be:
This will print out but... **********************************************************************/ }
![]()
abort -- Stop a Program
atexit -- Record Program Termination
Function
execl - _execvpe -- Load and Run Child
Process
exit -- End Program
onexit -- Record Termination Function
<process.h>
stdlib.h