diff options
author | Guillem Jover <guillem@debian.org> | 2015-09-17 02:00:14 +0200 |
---|---|---|
committer | Guillem Jover <guillem@debian.org> | 2015-09-17 04:38:43 +0200 |
commit | 21e982448e8dda1ac6c534303a8ba4f54b46127e (patch) | |
tree | 202077122c714db4efe6ee7d6ca2aca509ed89f4 /dselect/baselist.cc | |
parent | 908261815da543e2b9a4ec046e6859e68ea26431 (diff) | |
download | dpkg-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.cc | 21 |
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); |