]> granicus.if.org Git - procps-ng/commitdiff
top: do not catch SIGHUP, when operating in batch mode
authorJim Warner <james.warner@comcast.net>
Tue, 18 Dec 2012 06:00:00 +0000 (00:00 -0600)
committerCraig Small <csmall@enc.com.au>
Sat, 22 Dec 2012 06:10:11 +0000 (17:10 +1100)
This commit was adapted from the openSUSE patch, whose
original comments appear between the --- marker below.

It should be noted, however, that the original changes
were ineffective (wasted) because 'Batch' mode had not
yet been set when signals were being checked and their
handlers established. Thus, SIGHUP was never bypassed.

(of course, only our comments are perfectly justified)

------------------------------------------------------
Do not setup SIGHUP signal handler if we are in the batch mode

Top enables a signal handler for the SIGHUP signal (loss of terminal).  While
this makes sense for top's default interactive mode, it doesn't make any sense
for batch mode. If you run top in nohup just to collect data over time and
disconnect top finishes which is not what one would expect.
------------------------------------------------------

Reference(s):
http://www.freelists.org/post/procps/top-enhancements-i-hope,1

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

index c9678f96c553fdf189f9646c377bef53dcb45864..ea64770c11b5466d60d50babadf5284a51c2ddb7 100644 (file)
--- a/top/top.c
+++ b/top/top.c
@@ -3661,9 +3661,10 @@ static void wins_stage_2 (void) {
       Winstk[i].findstr = alloc_c(FNDBUFSIZ);
       Winstk[i].findlen = 0;
    }
-   if (Batch)
+   if (Batch) {
       OFFw(Curwin, View_SCROLL);
-
+      signal(SIGHUP, SIG_IGN);    // allow running under nohup
+   }
    // fill in missing Fieldstab members and build each window's columnhdr
    zap_fieldstab();
 } // end: wins_stage_2