Honor CRASDH_ON_ABORT

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@16708 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
CaS 2003-05-13 06:02:00 +00:00
parent dc15e6a960
commit 9b55d89555

View file

@ -37,14 +37,14 @@
static void static void
ihandler(int sig) ihandler(int sig)
{ {
int count; int i;
/* /*
* Reset signals to avoid recursive call of handler. * Reset signals to avoid recursive call of handler.
*/ */
for (count = 0; count < NSIG; count++) for (i = 0; i < NSIG; i++)
{ {
signal((int)count, SIG_DFL); signal(i, SIG_DFL);
} }
/* /*
* If asked to terminate, do so cleanly. * If asked to terminate, do so cleanly.
@ -53,11 +53,33 @@ ihandler(int sig)
{ {
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
/*
* Terminate with an abort ... should give us a core dump so we can #ifdef DEBUG
* debug and find out why this happened. i = 1; // abort() by default.
*/ #else
abort(); i = 0; // kill() or exit() by default.
#endif
e = getenv("CRASH_ON_ABORT");
if (e != 0)
{
if (strcasecmp(e, "yes") == 0 || strcasecmp(e, "true") == 0)
i = 1;
else if (strcasecmp(e, "no") == 0 || strcasecmp(e, "false") == 0)
i = 0;
else if (isdigit(*e) && *e != '0')
i = 1;
else
i = 0;
}
if (i == 1)
{
abort();
}
else
{
exit(sig);
}
} }