Syntax
#include <stdlib.h> /* also in <process.h> */ void _exit(int status);Description
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.
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> #include <stdlib.h> /* You can also use <process.h> */ char buf[51]; int main(void) { /* Make sure the standard output 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 ... ****************************************************************************/ }Related Information