Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 18 Jun 2018 02:06:16 +0000 (UTC)
From:      Eitan Adler <eadler@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r335310 - head/usr.bin/top
Message-ID:  <201806180206.w5I26GKG093032@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: eadler
Date: Mon Jun 18 02:06:16 2018
New Revision: 335310
URL: https://svnweb.freebsd.org/changeset/base/335310

Log:
  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.

Modified:
  head/usr.bin/top/top.c

Modified: head/usr.bin/top/top.c
==============================================================================
--- head/usr.bin/top/top.c	Sun Jun 17 23:08:54 2018	(r335309)
+++ head/usr.bin/top/top.c	Mon Jun 18 02:06:16 2018	(r335310)
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806180206.w5I26GKG093032>