/* * Copyright (c) 1990 Regents of the University of California. * All rights reserved. * * %sccs.include.redist.c% */ /* FUNCTION <>---end program execution INDEX exit SYNOPSIS #include void exit(int <[code]>); DESCRIPTION Use <> to return control from a program to the host operating environment. Use the argument <[code]> to pass an exit status to the operating environment: two particular values, <> and <>, are defined in `<>' to indicate success or failure in a portable fashion. <> does two kinds of cleanup before ending execution of your program. First, it calls all application-defined cleanup functions you have enrolled with <>. Second, files and streams are cleaned up: any pending output is delivered to the host system, each open file or stream is closed, and files created by <> are deleted. RETURNS <> does not return to its caller. PORTABILITY ANSI C requires <>, and specifies that <> and <> must be defined. Supporting OS subroutines required: <<_exit>>. */ #include #include /* for _exit() declaration */ #include #include "atexit.h" /* * Exit, flushing stdio buffers if necessary. */ void _DEFUN (exit, (code), int code) { #ifdef _LITE_EXIT /* Refer to comments in __atexit.c for more details of lite exit. */ void __call_exitprocs (int, void *)) __attribute__((weak); if (__call_exitprocs) #endif __call_exitprocs (code, NULL); if (_GLOBAL_REENT->__cleanup) (*_GLOBAL_REENT->__cleanup) (_GLOBAL_REENT); _exit (code); }