top: do not catch SIGHUP, when operating in batch mode

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>
This commit is contained in:
Jim Warner 2012-12-18 00:00:00 -06:00 committed by Craig Small
parent ced5009f75
commit 9f4e72b208

View File

@ -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