14fee23f9Smrg /* xexit.c -- Run any exit handlers, then exit.
2*b1e83836Smrg Copyright (C) 1994-2022 Free Software Foundation, Inc.
34fee23f9Smrg
44fee23f9Smrg This file is part of the libiberty library.
54fee23f9Smrg Libiberty is free software; you can redistribute it and/or
64fee23f9Smrg modify it under the terms of the GNU Library General Public
74fee23f9Smrg License as published by the Free Software Foundation; either
84fee23f9Smrg version 2 of the License, or (at your option) any later version.
94fee23f9Smrg
104fee23f9Smrg Libiberty is distributed in the hope that it will be useful,
114fee23f9Smrg but WITHOUT ANY WARRANTY; without even the implied warranty of
124fee23f9Smrg MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
134fee23f9Smrg Library General Public License for more details.
144fee23f9Smrg
154fee23f9Smrg You should have received a copy of the GNU Library General Public
164fee23f9Smrg License along with libiberty; see the file COPYING.LIB. If not, write
174fee23f9Smrg to the Free Software Foundation, Inc., 51 Franklin Street - Fifth Floor,
184fee23f9Smrg Boston, MA 02110-1301, USA. */
194fee23f9Smrg
204fee23f9Smrg /*
214fee23f9Smrg
224fee23f9Smrg @deftypefn Replacement void xexit (int @var{code})
234fee23f9Smrg
244fee23f9Smrg Terminates the program. If any functions have been registered with
254fee23f9Smrg the @code{xatexit} replacement function, they will be called first.
264fee23f9Smrg Termination is handled via the system's normal @code{exit} call.
274fee23f9Smrg
284fee23f9Smrg @end deftypefn
294fee23f9Smrg
304fee23f9Smrg */
314fee23f9Smrg
324fee23f9Smrg #ifdef HAVE_CONFIG_H
334fee23f9Smrg #include "config.h"
344fee23f9Smrg #endif
354fee23f9Smrg #include <stdio.h>
364fee23f9Smrg #ifdef HAVE_STDLIB_H
374fee23f9Smrg #include <stdlib.h>
384fee23f9Smrg #endif
394fee23f9Smrg #include "libiberty.h"
404fee23f9Smrg
414fee23f9Smrg
424fee23f9Smrg /* This variable is set by xatexit if it is called. This way, xmalloc
434fee23f9Smrg doesn't drag xatexit into the link. */
444fee23f9Smrg void (*_xexit_cleanup) (void);
454fee23f9Smrg
464fee23f9Smrg void
xexit(int code)474fee23f9Smrg xexit (int code)
484fee23f9Smrg {
494fee23f9Smrg if (_xexit_cleanup != NULL)
504fee23f9Smrg (*_xexit_cleanup) ();
514fee23f9Smrg exit (code);
524fee23f9Smrg }
53