]> granicus.if.org Git - procps-ng/commitdiff
top: follow ps lead, allow core dumps where applicable
authorJim Warner <james.warner@comcast.net>
Wed, 12 Dec 2012 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@enc.com.au>
Sat, 22 Dec 2012 06:07:39 +0000 (17:07 +1100)
Reference(s):
Bug-Redhat: https://bugzilla.redhat.com/871825
commit c1f10d11bc7fbab3af54a2b16e6db721b7e44f5c
http://www.freelists.org/post/procps/PATCH-Allow-core-file-generation-by-ps-command-rhbz871825-rhbz512857

Signed-off-by: Jim Warner <james.warner@comcast.net>
top/top.c
top/top.h
top/top_nls.c

index 2d3f63cc00a7bcce90a76bd02cd5dcb845c506b3..7df9388860b7408df329386b73b79dd700c2bf68 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -314,9 +314,8 @@ static const char *tg2 (int x, int y) {
 /*######  Exit/Interrput routines  #######################################*/
 
         /*
-         * The real program end */
-static void bye_bye (const char *str) NORETURN;
-static void bye_bye (const char *str) {
+         * Reset the tty, if necessary */
+static void at_eoj (void) {
    if (Ttychanged) {
       if (keypad_local) putp(keypad_local);
       tcsetattr(STDIN_FILENO, TCSAFLUSH, &Tty_original);
@@ -325,9 +324,18 @@ static void bye_bye (const char *str) {
 #ifndef RMAN_IGNORED
       putp(Cap_smam);
 #endif
+      putp("\n");
+      Ttychanged = 0;
    }
    fflush(stdout);
+} // end:
+
 
+        /*
+         * The real program end */
+static void bye_bye (const char *str) NORETURN;
+static void bye_bye (const char *str) {
+   at_eoj();                 // restore tty in preparation for exit
 #ifdef ATEOJ_RPTSTD
 {  proc_t *p;
    if (!str && Ttychanged) { fprintf(stderr,
@@ -478,7 +486,6 @@ static void bye_bye (const char *str) {
       fputs(str, stderr);
       exit(EXIT_FAILURE);
    }
-   putp("\n");
    exit(EXIT_SUCCESS);
 } // end: bye_bye
 
@@ -535,13 +542,16 @@ static void pause_pgm (void) {
 
         /*
          * Catches all remaining signals not otherwise handled */
-static void sig_abexit (int sig) NORETURN;
 static void sig_abexit (int sig) {
    sigset_t ss;
 
    sigfillset(&ss);
    sigprocmask(SIG_BLOCK, &ss, NULL);
-   bye_bye(fmtmk(N_fmt(EXIT_signals_fmt), sig, signal_number_to_name(sig), Myname));
+   at_eoj();                 // restore tty in preparation for exit
+   fprintf(stderr, N_fmt(EXIT_signals_fmt)
+      , sig, signal_number_to_name(sig), Myname);
+   signal(sig, SIG_DFL);     // allow core dumps, if applicable
+   raise(sig);               // ( plus set proper return code )
 } // end: sig_abexit
 
 
index 7f8e96f0f6c22bd9453b17ca1d63e5249f6694db..9f052305bb84d6250072242536b42841398d4405 100644 (file)
--- a/top/top.h
+++ b/top/top.h
@@ -600,6 +600,7 @@ typedef struct WIN_t {
 //atic inline char  *scat (char *dst, const char *src);
 //atic const char   *tg2 (int x, int y);
 /*------  Exit/Interrput routines  ---------------------------------------*/
+//atic void          at_eoj (void);
 //atic void          bye_bye (const char *str);
 //atic void          error_exit (const char *str);
 //atic void          library_err (const char *fmts, ...);
index 16ce5fb81098e22217a425ae80f6c90d38e98e94..80d9b080d1dc3758905f976f9de2befe9f98560a 100644 (file)
@@ -273,7 +273,7 @@ static void build_norm_nlstab (void) {
    .  c-code logic changes.
    . */
 
-   Norm_nlstab[EXIT_signals_fmt] = _("\n"
+   Norm_nlstab[EXIT_signals_fmt] = _(""
       "\tsignal %d (%s) was caught by %s, please\n"
       "\tsee http://www.debian.org/Bugs/Reporting\n");
    Norm_nlstab[WRONG_switch_fmt] = _(""