EXIT(DOS) XENIX System V EXIT(DOS)
Name
exit - Terminates the calling process.
Syntax
#include <process.h>
void exit (status);
void _exit (status);
int status;
Description
The exit and _exit functions terminate the calling process.
exit flushes all buffers and closes all open files before
terminating the process. _exit terminates the process
without flushing stream buffers. Status is typically given
the value 0 to indicate a normal exit and set to some other
value to indicate an error.
Although the exit and _exit calls do not return a value, the
low-order byte of status is made available to the waiting
parent process, if there is one, after the calling process
exits. If there is no parent process waiting on the exiting
process, the status value is lost.
Return Value
There is no return value.
See Also
abort(S), exec(S), spawn(DOS)
Page 1 (printed 8/7/87)
EXIT(DOS) XENIX System V EXIT(DOS)
Example
#include <process.h> #include <stdio.h>
FILE *stream;
.
.
. /* The following statements cause the process to **
terminate, after flushing buffers and closing ** open files,
if another file cannot be opened. */
if ((stream = fopen ("data","r")) == NULL) { perror
("couldn't open data file"); exit (1); }
/* The following statements cause the process to **
terminate immediately if a file cannot be opened. */
if ((stream = fopen ("data","r")) == NULL) { perror
("couldn't open data file"); exit (1); }
Notes
These calls must be compiled with the -dos flag.
Page 2 (printed 8/7/87)