mirror of
https://github.com/gnustep/libs-base.git
synced 2025-05-30 16:30:41 +00:00
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:
parent
fe96343fc7
commit
77cf84a62f
1 changed files with 30 additions and 8 deletions
38
Tools/gdnc.m
38
Tools/gdnc.m
|
@ -37,14 +37,14 @@
|
|||
static void
|
||||
ihandler(int sig)
|
||||
{
|
||||
int count;
|
||||
int i;
|
||||
|
||||
/*
|
||||
* 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.
|
||||
|
@ -53,11 +53,33 @@ ihandler(int sig)
|
|||
{
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
/*
|
||||
* Terminate with an abort ... should give us a core dump so we can
|
||||
* debug and find out why this happened.
|
||||
*/
|
||||
abort();
|
||||
|
||||
#ifdef DEBUG
|
||||
i = 1; // abort() by default.
|
||||
#else
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue