summaryrefslogtreecommitdiff
path: root/dselect/baselist.cc
diff options
context:
space:
mode:
authorGuillem Jover <guillem@debian.org>2015-09-17 02:00:14 +0200
committerGuillem Jover <guillem@debian.org>2015-09-17 04:38:43 +0200
commit21e982448e8dda1ac6c534303a8ba4f54b46127e (patch)
tree202077122c714db4efe6ee7d6ca2aca509ed89f4 /dselect/baselist.cc
parent908261815da543e2b9a4ec046e6859e68ea26431 (diff)
downloaddpkg-21e982448e8dda1ac6c534303a8ba4f54b46127e.tar.gz
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.
Diffstat (limited to 'dselect/baselist.cc')
-rw-r--r--dselect/baselist.cc21
1 files changed, 18 insertions, 3 deletions
diff --git a/dselect/baselist.cc b/dselect/baselist.cc
index 8e2f44f65..6c1aad9c6 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);