1 /* Copyright (C) 1991, 1993, 1995, 1996 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public License as
6 published by the Free Software Foundation; either version 2 of the
7 License, or (at your option) any later version.
9 The GNU C Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details.
14 You should have received a copy of the GNU Library General Public
15 License along with the GNU C Library; see the file COPYING.LIB. If not,
16 write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. */
26 /* Function to close all streams and also make sure we don't loop by
27 calling abort while closing the streams. */
28 extern void __close_all_streams (void);
31 /* Cause an abnormal program termination with core-dump. */
38 if (__sigemptyset (&sigs
) == 0 &&
39 __sigaddset (&sigs
, SIGABRT
) == 0)
40 __sigprocmask (SIG_UNBLOCK
, &sigs
, (sigset_t
*) NULL
);
42 /* If there is a user handler installed use it. We don't close or
44 if (__sigaction (SIGABRT
, NULL
, &act
) >= 0
45 && act
.sa_handler
!= SIG_DFL
)
47 /* Send signal to call user handler. */
50 /* It returns, so we are responsible for closing the streams. */
51 __close_all_streams ();
53 /* There was a handler installed. Now remove it. */
54 memset (&act
, '\0', sizeof (struct sigaction
));
55 act
.sa_handler
= SIG_DFL
;
56 __sigfillset (&act
.sa_mask
);
58 __sigaction (SIGABRT
, &act
, NULL
);
61 /* No handler installed so the next `raise' will hopefully
62 terminate the process. Therefore we must close the streams. */
63 __close_all_streams ();
68 /* If we can't signal ourselves, exit. */
71 /* If even this fails make sure we never return. */
73 /* For ever and ever. */