1169695Skan/* xexit.c -- Run any exit handlers, then exit. 2169695Skan Copyright (C) 1994, 95, 1997 Free Software Foundation, Inc. 3169695Skan 4169695SkanThis file is part of the libiberty library. 5169695SkanLibiberty is free software; you can redistribute it and/or 6169695Skanmodify it under the terms of the GNU Library General Public 7169695SkanLicense as published by the Free Software Foundation; either 8169695Skanversion 2 of the License, or (at your option) any later version. 9169695Skan 10169695SkanLibiberty is distributed in the hope that it will be useful, 11169695Skanbut WITHOUT ANY WARRANTY; without even the implied warranty of 12169695SkanMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13169695SkanLibrary General Public License for more details. 14169695Skan 15169695SkanYou should have received a copy of the GNU Library General Public 16169695SkanLicense along with libiberty; see the file COPYING.LIB. If not, write 17169695Skanto the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor, 18169695SkanBoston, MA 02110-1301, USA. */ 19169695Skan 20169695Skan/* 21169695Skan 22169695Skan@deftypefn Replacement void xexit (int @var{code}) 23169695Skan 24169695SkanTerminates the program. If any functions have been registered with 25169695Skanthe @code{xatexit} replacement function, they will be called first. 26169695SkanTermination is handled via the system's normal @code{exit} call. 27169695Skan 28169695Skan@end deftypefn 29169695Skan 30169695Skan*/ 31169695Skan 32169695Skan#ifdef HAVE_CONFIG_H 33169695Skan#include "config.h" 34169695Skan#endif 35169695Skan#include <stdio.h> 36169695Skan#ifdef HAVE_STDLIB_H 37169695Skan#include <stdlib.h> 38169695Skan#endif 39169695Skan#include "libiberty.h" 40169695Skan 41169695Skan 42169695Skan/* This variable is set by xatexit if it is called. This way, xmalloc 43169695Skan doesn't drag xatexit into the link. */ 44169695Skanvoid (*_xexit_cleanup) (void); 45169695Skan 46169695Skanvoid 47169695Skanxexit (int code) 48169695Skan{ 49169695Skan if (_xexit_cleanup != NULL) 50169695Skan (*_xexit_cleanup) (); 51169695Skan exit (code); 52169695Skan} 53