diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index 6314cda0aedf..abaeca2962d0 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -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);