diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2001-09-04 23:36:00 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2001-09-04 23:36:00 +0000 |
commit | 6e69b2a3e9a34411460d33a432a805b3eb1924d1 (patch) | |
tree | 33cfe52f5da9645a00ca15af49ceefdd612696d2 /usr.bin/top/top.c | |
parent | 102264589c8731b5f0fb00b204e5963726ecec83 (diff) |
Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.
Diffstat (limited to 'usr.bin/top/top.c')
-rw-r--r-- | usr.bin/top/top.c | 39 |
1 files changed, 12 insertions, 27 deletions
diff --git a/usr.bin/top/top.c b/usr.bin/top/top.c index 78e99f65090..04f82233d6b 100644 --- a/usr.bin/top/top.c +++ b/usr.bin/top/top.c @@ -1,4 +1,4 @@ -/* $OpenBSD: top.c,v 1.9 2001/07/27 17:13:42 deraadt Exp $ */ +/* $OpenBSD: top.c,v 1.10 2001/09/04 23:35:59 millert Exp $ */ const char copyright[] = "Copyright (c) 1984 through 1996, William LeFebvre"; @@ -25,8 +25,6 @@ const char copyright[] = "Copyright (c) 1984 through 1996, William LeFebvre"; * The following preprocessor variables, when defined, are used to * distinguish between different Unix implementations: * - * SIGHOLD - use SVR4 sighold function when defined - * SIGRELSE - use SVR4 sigrelse function when defined * FD_SET - macros FD_SET and FD_ZERO are used when defined */ @@ -56,9 +54,6 @@ const char copyright[] = "Copyright (c) 1984 through 1996, William LeFebvre"; /* The buffer that stdio will use */ char stdoutbuf[Buffersize]; -/* build Signal masks */ -#define Smask(s) (1 << ((s) - 1)) - /* imported from screen.c */ extern int overstrike; @@ -120,7 +115,7 @@ char *argv[]; static char tempbuf1[50]; static char tempbuf2[50]; - int old_sigmask; /* only used for BSD-style signals */ + sigset_t mask, oldmask; int topn = Default_TOPN; int delay = Default_DELAY; int displays = 0; /* indicates unspecified */ @@ -457,14 +452,12 @@ Usage: %s [-ISbinqu] [-d x] [-s x] [-o field] [-U username] [number]\n", displays = smart_terminal ? Infinity : 1; } - /* hold interrupt signals while setting up the screen and the handlers */ -#ifdef SIGHOLD - sighold(SIGINT); - sighold(SIGQUIT); - sighold(SIGTSTP); -#else - old_sigmask = sigblock(Smask(SIGINT) | Smask(SIGQUIT) | Smask(SIGTSTP)); -#endif + /* block interrupt signals while setting up the screen and the handlers */ + sigemptyset(&mask); + sigaddset(&mask, SIGINT); + sigaddset(&mask, SIGQUIT); + sigaddset(&mask, SIGTSTP); + sigprocmask(SIG_BLOCK, &mask, &oldmask); init_screen(); (void) signal(SIGINT, leave); (void) signal(SIGQUIT, leave); @@ -472,13 +465,7 @@ Usage: %s [-ISbinqu] [-d x] [-s x] [-o field] [-U username] [number]\n", #ifdef SIGWINCH (void) signal(SIGWINCH, winch); #endif -#ifdef SIGRELSE - sigrelse(SIGINT); - sigrelse(SIGQUIT); - sigrelse(SIGTSTP); -#else - (void) sigsetmask(old_sigmask); -#endif + sigprocmask(SIG_SETMASK, &oldmask, NULL); if (warnings) { fputs("....", stderr); @@ -640,11 +627,9 @@ restart: (void) signal(SIGTSTP, SIG_DFL); /* unblock the signal and send ourselves one */ -#ifdef SIGRELSE - sigrelse(SIGTSTP); -#else - (void) sigsetmask(sigblock(0) & ~(1 << (SIGTSTP - 1))); -#endif + sigemptyset(&mask); + sigaddset(&mask, SIGTSTP); + sigprocmask(SIG_UNBLOCK, &mask, NULL); (void) kill(0, SIGTSTP); /* reset the signal handler */ |