Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ambrop72/badvpn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAmbroz Bizjak <ambrop7@gmail.com>2016-08-17 22:34:21 +0300
committerAmbroz Bizjak <ambrop7@gmail.com>2016-08-17 22:34:21 +0300
commit64f30f5480fef88edb8f633ffecdbc181f0a6900 (patch)
tree89513b8470a9abd1cae97d33970740acbc08e98f
parent1e45405d7e9355821e941e314f1b221556983f50 (diff)
Fix usage of sigprocmask() to pthread_sigmask().
-rw-r--r--system/BProcess.c8
-rw-r--r--system/BUnixSignal.c17
-rw-r--r--system/BUnixSignal.h4
3 files changed, 15 insertions, 14 deletions
diff --git a/system/BProcess.c b/system/BProcess.c
index 368db4e..19c5ac1 100644
--- a/system/BProcess.c
+++ b/system/BProcess.c
@@ -274,8 +274,8 @@ int BProcess_Init2 (BProcess *o, BProcessManager *m, BProcess_handler handler, v
sigset_t sset_all;
sigfillset(&sset_all);
sigset_t sset_old;
- if (sigprocmask(SIG_SETMASK, &sset_all, &sset_old) < 0) {
- BLog(BLOG_ERROR, "sigprocmask failed");
+ if (pthread_sigmask(SIG_SETMASK, &sset_all, &sset_old) != 0) {
+ BLog(BLOG_ERROR, "pthread_sigmask failed");
goto fail3;
}
@@ -297,7 +297,7 @@ int BProcess_Init2 (BProcess *o, BProcessManager *m, BProcess_handler handler, v
// unblock signals
sigset_t sset_none;
sigemptyset(&sset_none);
- if (sigprocmask(SIG_SETMASK, &sset_none, NULL) < 0) {
+ if (pthread_sigmask(SIG_SETMASK, &sset_none, NULL) != 0) {
abort();
}
@@ -365,7 +365,7 @@ int BProcess_Init2 (BProcess *o, BProcessManager *m, BProcess_handler handler, v
}
// restore original signal mask
- ASSERT_FORCE(sigprocmask(SIG_SETMASK, &sset_old, NULL) == 0)
+ ASSERT_FORCE(pthread_sigmask(SIG_SETMASK, &sset_old, NULL) == 0)
if (pid < 0) {
BLog(BLOG_ERROR, "fork failed");
diff --git a/system/BUnixSignal.c b/system/BUnixSignal.c
index 94edd6b..d24655d 100644
--- a/system/BUnixSignal.c
+++ b/system/BUnixSignal.c
@@ -33,6 +33,7 @@
#include <errno.h>
#include <fcntl.h>
#include <string.h>
+#include <signal.h>
#ifdef BADVPN_USE_SIGNALFD
#include <sys/signalfd.h>
@@ -189,8 +190,8 @@ int BUnixSignal_Init (BUnixSignal *o, BReactor *reactor, sigset_t signals, BUnix
BReactor_SetFileDescriptorEvents(o->reactor, &o->signalfd_bfd, BREACTOR_READ);
// block signals
- if (sigprocmask(SIG_BLOCK, &o->signals, 0) < 0) {
- BLog(BLOG_ERROR, "sigprocmask block failed");
+ if (pthread_sigmask(SIG_BLOCK, &o->signals, 0) != 0) {
+ BLog(BLOG_ERROR, "pthread_sigmask block failed");
goto fail2;
}
@@ -230,8 +231,8 @@ int BUnixSignal_Init (BUnixSignal *o, BReactor *reactor, sigset_t signals, BUnix
}
// block signals
- if (sigprocmask(SIG_BLOCK, &o->signals, 0) < 0) {
- BLog(BLOG_ERROR, "sigprocmask block failed");
+ if (pthread_sigmask(SIG_BLOCK, &o->signals, 0) != 0) {
+ BLog(BLOG_ERROR, "pthread_sigmask block failed");
goto fail2;
}
@@ -355,7 +356,7 @@ void BUnixSignal_Free (BUnixSignal *o, int unblock)
if (unblock) {
// unblock signals
- ASSERT_FORCE(sigprocmask(SIG_UNBLOCK, &o->signals, 0) == 0)
+ ASSERT_FORCE(pthread_sigmask(SIG_UNBLOCK, &o->signals, 0) == 0)
}
// free signalfd BFileDescriptor
@@ -370,7 +371,7 @@ void BUnixSignal_Free (BUnixSignal *o, int unblock)
if (unblock) {
// unblock signals
- ASSERT_FORCE(sigprocmask(SIG_UNBLOCK, &o->signals, 0) == 0)
+ ASSERT_FORCE(pthread_sigmask(SIG_UNBLOCK, &o->signals, 0) == 0)
}
// free kevents
@@ -388,8 +389,8 @@ void BUnixSignal_Free (BUnixSignal *o, int unblock)
if (!unblock) {
// block signals
- if (sigprocmask(SIG_BLOCK, &o->signals, 0) < 0) {
- BLog(BLOG_ERROR, "sigprocmask block failed");
+ if (pthread_sigmask(SIG_BLOCK, &o->signals, 0) != 0) {
+ BLog(BLOG_ERROR, "pthread_sigmask block failed");
}
}
diff --git a/system/BUnixSignal.h b/system/BUnixSignal.h
index 2438be9..c7aa389 100644
--- a/system/BUnixSignal.h
+++ b/system/BUnixSignal.h
@@ -106,7 +106,7 @@ typedef struct BUnixSignal_s {
* WARNING: for every signal number there should be at most one {@link BUnixSignal}
* object handling it (or anything else that could interfere).
*
- * This blocks the signal using sigprocmask() and sets up signalfd() for receiving
+ * This blocks the signal using pthread_sigmask() and sets up signalfd() for receiving
* signals.
*
* @param o the object
@@ -122,7 +122,7 @@ int BUnixSignal_Init (BUnixSignal *o, BReactor *reactor, sigset_t signals, BUnix
* Frees the object.
*
* @param o the object
- * @param unblock whether to unblock the signals using sigprocmask(). Not unblocking it
+ * @param unblock whether to unblock the signals using pthread_sigmask(). Not unblocking it
* can be used while the program is exiting gracefully to prevent the
* signals from being handled handled according to its default disposition
* after this function is called. Must be 0 or 1.