[Reproducible-commits] [dpkg] 42/61: dselect: Refactor SIGWINCH signal blocking and unblocking

Jérémy Bobbio lunar at moszumanska.debian.org
Mon Sep 21 09:57:39 UTC 2015


This is an automated email from the git hooks/post-receive script.

lunar pushed a commit to branch pu/reproducible_builds
in repository dpkg.

commit 21e982448e8dda1ac6c534303a8ba4f54b46127e
Author: Guillem Jover <guillem at debian.org>
Date:   Thu Sep 17 02:00:14 2015 +0200

    dselect: Refactor SIGWINCH signal blocking and unblocking
    
    This way we can move the sigset_t sigwinchset declaration into the
    new sigwinch_mask() member function instead of having it as a member
    variable.
---
 dselect/baselist.cc | 21 ++++++++++++++++++---
 dselect/dselect.h   |  3 ++-
 dselect/methlist.cc |  6 ++----
 dselect/pkglist.cc  |  6 ++----
 4 files changed, 24 insertions(+), 12 deletions(-)

diff --git a/dselect/baselist.cc b/dselect/baselist.cc
index 8e2f44f..6c1aad9 100644
--- a/dselect/baselist.cc
+++ b/dselect/baselist.cc
@@ -76,10 +76,25 @@ static void cu_sigwinch(int, void **argv) {
   delete oblockedp;
 }
 
-void baselist::setupsigwinch() {
+void
+baselist::sigwinch_mask(int how)
+{
+  sigset_t sigwinchset;
   sigemptyset(&sigwinchset);
   sigaddset(&sigwinchset,SIGWINCH);
 
+  int rc = sigprocmask(how, &sigwinchset, nullptr);
+  if (rc < 0) {
+    if (how == SIG_UNBLOCK)
+      ohshite(_("failed to unblock SIGWINCH"));
+    else
+      ohshite(_("failed to block SIGWINCH"));
+  }
+}
+
+void
+baselist::setupsigwinch()
+{
   osigactp= new(struct sigaction);
   oblockedp= new(sigset_t);
   if (sigprocmask(0, nullptr, oblockedp))
@@ -89,8 +104,8 @@ void baselist::setupsigwinch() {
 
   push_cleanup(cu_sigwinch, ~0, nullptr, 0, 2, osigactp, oblockedp);
 
-  if (sigprocmask(SIG_BLOCK, &sigwinchset, nullptr))
-    ohshite(_("failed to block SIGWINCH"));
+  sigwinch_mask(SIG_BLOCK);
+
   memset(&nsigact,0,sizeof(nsigact));
   nsigact.sa_handler= sigwinchhandler;
   sigemptyset(&nsigact.sa_mask);
diff --git a/dselect/dselect.h b/dselect/dselect.h
index 69434ee..9b95331 100644
--- a/dselect/dselect.h
+++ b/dselect/dselect.h
@@ -99,7 +99,8 @@ protected:
 
   // SIGWINCH handling
   struct sigaction *osigactp, nsigact;
-  sigset_t *oblockedp, sigwinchset;
+  sigset_t *oblockedp;
+  void sigwinch_mask(int how);
   void setupsigwinch();
 
   static baselist *signallist;
diff --git a/dselect/methlist.cc b/dselect/methlist.cc
index 9ce220c..b9fe3cc 100644
--- a/dselect/methlist.cc
+++ b/dselect/methlist.cc
@@ -160,13 +160,11 @@ quitaction methodlist::display() {
     if (whatinfo_height) wcursyncup(whatinfowin);
     if (doupdate() == ERR) ohshite(_("doupdate failed"));
     signallist= this;
-    if (sigprocmask(SIG_UNBLOCK, &sigwinchset, nullptr))
-      ohshite(_("failed to unblock SIGWINCH"));
+    sigwinch_mask(SIG_UNBLOCK);
     do
     response= getch();
     while (response == ERR && errno == EINTR);
-    if (sigprocmask(SIG_BLOCK, &sigwinchset, nullptr))
-      ohshite(_("failed to re-block SIGWINCH"));
+    sigwinch_mask(SIG_BLOCK);
     if (response == ERR) ohshite(_("getch failed"));
     interp= (*bindings)(response);
     debug(dbg_general, "methodlist[%p]::display() response=%d interp=%s",
diff --git a/dselect/pkglist.cc b/dselect/pkglist.cc
index 5607b56..f6be187 100644
--- a/dselect/pkglist.cc
+++ b/dselect/pkglist.cc
@@ -586,13 +586,11 @@ pkginfo **packagelist::display() {
     if (doupdate() == ERR)
       ohshite(_("doupdate failed"));
     signallist= this;
-    if (sigprocmask(SIG_UNBLOCK, &sigwinchset, nullptr))
-      ohshite(_("failed to unblock SIGWINCH"));
+    sigwinch_mask(SIG_UNBLOCK);
     do
     response= getch();
     while (response == ERR && errno == EINTR);
-    if (sigprocmask(SIG_BLOCK, &sigwinchset, nullptr))
-      ohshite(_("failed to re-block SIGWINCH"));
+    sigwinch_mask(SIG_BLOCK);
     if (response == ERR)
       ohshite(_("getch failed"));
     interp= (*bindings)(response);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list