top(1): use more modern signal code
Rather than manually build signal masks use functions designed for that reason. Also use sigprocmask instead of sigblock.
This commit is contained in:
parent
755e4b7936
commit
6bb0d5cf77
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=335310
@ -50,10 +50,6 @@ typedef void sigret_t;
|
||||
/* The buffer that stdio will use */
|
||||
static char stdoutbuf[Buffersize];
|
||||
|
||||
/* build Signal masks */
|
||||
#define Smask(s) (1 << ((s) - 1))
|
||||
|
||||
|
||||
static int fmt_flags = 0;
|
||||
int pcpu_stats = false;
|
||||
|
||||
@ -233,7 +229,7 @@ main(int argc, char *argv[])
|
||||
|
||||
static char tempbuf1[50];
|
||||
static char tempbuf2[50];
|
||||
int old_sigmask; /* only used for BSD-style signals */
|
||||
sigset_t old_sigmask, new_sigmask;
|
||||
int topn = Infinity;
|
||||
double delay = 2;
|
||||
int displays = 0; /* indicates unspecified */
|
||||
@ -591,13 +587,18 @@ main(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* hold interrupt signals while setting up the screen and the handlers */
|
||||
old_sigmask = sigblock(Smask(SIGINT) | Smask(SIGQUIT) | Smask(SIGTSTP));
|
||||
|
||||
sigemptyset(&new_sigmask);
|
||||
sigaddset(&new_sigmask, SIGINT);
|
||||
sigaddset(&new_sigmask, SIGQUIT);
|
||||
sigaddset(&new_sigmask, SIGTSTP);
|
||||
sigprocmask(SIG_BLOCK, &new_sigmask, &old_sigmask);
|
||||
init_screen();
|
||||
signal(SIGINT, leave);
|
||||
signal(SIGQUIT, leave);
|
||||
signal(SIGTSTP, tstop);
|
||||
signal(SIGWINCH, top_winch);
|
||||
sigsetmask(old_sigmask);
|
||||
sigprocmask(SIG_SETMASK, &old_sigmask, NULL);
|
||||
if (warnings)
|
||||
{
|
||||
fputs("....", stderr);
|
||||
|
Loading…
Reference in New Issue
Block a user