John Darrington <[email protected]> writes: > I think that the exit status in the function request_bug_report_and_abort > should be something which is neither EXIT_FAILURE nor EXIT_SUCCESS. We > need an EXIT_CATASTROPHY
The customary way to do this is to re-raise the signal that caused the failure, so that the calling process sees that signal. I pushed this: --8<--------------------------cut here-------------------------->8-- From: Ben Pfaff <[email protected]> Date: Sat, 2 Oct 2010 10:21:21 -0700 Subject: [PATCH] pspp: Make a signal that indicates a bug re-raise that signal to exit. John Darrington pointed out that exiting with EXIT_FAILURE isn't nearly emphatic enough here. --- src/libpspp/message.c | 4 +--- src/libpspp/message.h | 2 +- src/ui/terminal/main.c | 15 +++++++++++---- 3 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/libpspp/message.c b/src/libpspp/message.c index 0ca2749..ed6d6e7 100644 --- a/src/libpspp/message.c +++ b/src/libpspp/message.c @@ -312,7 +312,7 @@ msg_enable (void) /* Private functions. */ void -request_bug_report_and_abort (const char *msg) +request_bug_report (const char *msg) { fprintf (stderr, "******************************************************\n"); fprintf (stderr, "You have discovered a bug in PSPP. Please report this\n"); @@ -334,7 +334,5 @@ request_bug_report_and_abort (const char *msg) #endif ); fprintf (stderr, "******************************************************\n"); - - _exit (EXIT_FAILURE); } diff --git a/src/libpspp/message.h b/src/libpspp/message.h index 7c11101..fad7816 100644 --- a/src/libpspp/message.h +++ b/src/libpspp/message.h @@ -117,7 +117,7 @@ void msg_ui_disable_warnings (bool); /* Used in panic situations only. */ -void request_bug_report_and_abort (const char *msg) NO_RETURN; +void request_bug_report (const char *msg); #endif /* message.h */ diff --git a/src/ui/terminal/main.c b/src/ui/terminal/main.c index 94b21a5..7d2c97f 100644 --- a/src/ui/terminal/main.c +++ b/src/ui/terminal/main.c @@ -155,20 +155,27 @@ fpu_init (void) void bug_handler(int sig) { + /* Reset SIG to its default handling so that if it happens again we won't + recurse. */ + signal (sig, SIG_DFL); + #if DEBUGGING connect_debugger (); #endif switch (sig) { case SIGABRT: - request_bug_report_and_abort("Assertion Failure/Abort"); + request_bug_report("Assertion Failure/Abort"); case SIGFPE: - request_bug_report_and_abort("Floating Point Exception"); + request_bug_report("Floating Point Exception"); case SIGSEGV: - request_bug_report_and_abort("Segmentation Violation"); + request_bug_report("Segmentation Violation"); default: - request_bug_report_and_abort("Unknown"); + request_bug_report("Unknown"); } + + /* Re-raise the signal so that we terminate with the correct status. */ + raise (sig); } /* Clean up PSPP in preparation for termination. */ -- Ben Pfaff http://benpfaff.org _______________________________________________ pspp-dev mailing list [email protected] http://lists.gnu.org/mailman/listinfo/pspp-dev
