From: Jim Warner Date: Tue, 18 Dec 2012 06:00:00 +0000 (-0600) Subject: top: do not catch SIGHUP, when operating in batch mode X-Git-Tag: v3.3.6~18 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9f4e72b208bad8e2cb1314cf485d3854a574ebec;p=procps-ng 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 --- diff --git a/top/top.c b/top/top.c index c9678f96..ea64770c 100644 --- 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