ps: add catastrophic_failure()

The catastrophic_failure function tries to make bug reporting useful
by telling in which line error occured, and drops core.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola
2012-01-10 21:47:11 +01:00
parent bf88c882ed
commit 809906b6a7
6 changed files with 23 additions and 14 deletions

View File

@@ -41,15 +41,13 @@ static void signal_handler(int signo){
if(signo==SIGPIPE) _exit(0); /* "ps | head" will cause this */
/* fprintf() is not reentrant, but we _exit() anyway */
fprintf(stderr,
_("\n\n"
"Signal %d (%s) caught by %s (%s).\n"
"Please send bug reports to <procps@freelists.org>\n"),
_("Signal %d (%s) caught by %s (%s).\n"),
signo,
signal_number_to_name(signo),
myname,
procps_version
);
_exit(signo+128);
catastrophic_failure(__FILE__, __LINE__, _("please report this bug"));
}
/////////////////////////////////////////////////////////////////////////////////////
@@ -250,7 +248,7 @@ static void lists_and_needs(void){
t_end->need = 0;
break;
default:
fprintf(stderr, _("please report this bug\n"));
catastrophic_failure(__FILE__, __LINE__, _("please report this bug"));
// FALL THROUGH
case CF_PRINT_AS_NEEDED:
case CF_PRINT_EVERY_TIME: