exit(3C)
_________________________________________________________________
exit function
Flush buffers and terminate the process normally.
_________________________________________________________________
Calling Sequence
void exit();
int status;
exit(status);
where status is a return value.
Description
The exit function flushes the buffers and terminates the process
normally; it closes all the files of the process. The exit
function also notifies the parent process if it is executing a
wait function (see the description in Chapter 2 of Using
Specialized C Functions). The parent can use the low-order eight
status bits; the status value must be between 0 and 255.
See the "Input/Output Functions and Macros" section of Chapter 1
for information on buffering with the exit function.
This function is the same as the exit function described in
Chapter 2 of Using Specialized C Functions.
Returns
If the function has a nonzero argument, it represents an error
code to be passed back to the parent process. If the current
process was invoked by a C program using one of the exec
functions, the return value is limited to 8 bits (0 - 255). A 0
value typically means no error occurred.
Related Functions
See also the abort and dg_abort functions, described in this
chapter, and the exec, wait, and vfork functions, described in
Chapter 2 of Using Specialized C Functions.
Example
/* Program test for the exit() function */
DG/UX 4.00 Page 1
Licensed material--property of copyright holder(s)
exit(3C)
#include <stdio.h>
int err, atoi(), exit();
main(argc, argv)
int argc;
char *argv[];
{
err = atoi(argv[1]);
exit(err);
}
If you call the program test with an argument of 256, you receive
the message
*WARNING*
Program 'exit'ed with a status of 0400
WARNING: FROM PROGRAM
DG/UX 4.00 Page 2
Licensed material--property of copyright holder(s)