[CRIU] [PATCH 2/2] zdtm: check signal blocking mask in static/sigpending
Andrey Vagin
avagin at openvz.org
Wed Apr 24 12:09:20 EDT 2013
Signed-off-by: Andrey Vagin <avagin at openvz.org>
---
test/zdtm/live/static/sigpending.c | 30 ++++++++++++++++++++++++++----
1 file changed, 26 insertions(+), 4 deletions(-)
diff --git a/test/zdtm/live/static/sigpending.c b/test/zdtm/live/static/sigpending.c
index 040c39b..ce47f60 100644
--- a/test/zdtm/live/static/sigpending.c
+++ b/test/zdtm/live/static/sigpending.c
@@ -5,6 +5,8 @@
#include <sys/syscall.h>
#include <pthread.h>
#include <string.h>
+#include <limits.h>
+
#include "zdtmtst.h"
const char *test_doc = "Check pending signals";
@@ -86,7 +88,7 @@ static int thread_id;
static void *thread_fn(void *args)
{
- sigset_t blockmask;
+ sigset_t blockmask, oldset, newset;
struct sigaction act;
sigfillset(&blockmask);
@@ -97,6 +99,11 @@ static void *thread_fn(void *args)
return NULL;
}
+ if (sigprocmask(SIG_BLOCK, NULL, &oldset) == -1) {
+ err("sigprocmask");
+ return NULL;
+ }
+
thread_id = syscall(SYS_gettid);
act.sa_flags = SA_SIGINFO | SA_RESTART;
@@ -113,11 +120,16 @@ static void *thread_fn(void *args)
pthread_mutex_unlock(&init_lock);
pthread_mutex_lock(&exit_lock);
- if (sigprocmask(SIG_UNBLOCK, &blockmask, NULL) == -1) {
+ if (sigprocmask(SIG_UNBLOCK, &blockmask, &newset) == -1) {
err("sigprocmask");
return NULL;
}
+ if (!memcmp(&newset, &oldset, sizeof(newset))) {
+ fail("The signal blocking mask was changed");
+ numsig = INT_MAX;
+ }
+
return NULL;
}
@@ -144,7 +156,7 @@ int send_siginfo(int signo, pid_t pid, pid_t tid, int group, siginfo_t *info)
int main(int argc, char ** argv)
{
- sigset_t blockmask;
+ sigset_t blockmask, oldset, newset;
struct sigaction act;
pthread_t pthrd;
int i;
@@ -170,6 +182,11 @@ int main(int argc, char ** argv)
return -1;
}
+ if (sigprocmask(SIG_BLOCK, &oldset, NULL) == -1) {
+ err("sigprocmask");
+ return -1;
+ }
+
child = fork();
if (child == -1) {
err("fork");
@@ -218,13 +235,18 @@ int main(int argc, char ** argv)
test_waitsig();
- if (sigprocmask(SIG_UNBLOCK, &blockmask, NULL) == -1) {
+ if (sigprocmask(SIG_UNBLOCK, &blockmask, &newset) == -1) {
err("sigprocmask");
return -1;
}
pthread_mutex_unlock(&exit_lock);
pthread_join(pthrd, NULL);
+ if (!memcmp(&newset, &oldset, sizeof(newset))) {
+ fail("The signal blocking mask was changed");
+ return 1;
+ }
+
if (numsig == sent_sigs)
pass();
--
1.8.2
More information about the CRIU
mailing list