Commit 83d4ceb8 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm: check signal blocking mask in static/sigpending

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ae729638
...@@ -5,6 +5,8 @@ ...@@ -5,6 +5,8 @@
#include <sys/syscall.h> #include <sys/syscall.h>
#include <pthread.h> #include <pthread.h>
#include <string.h> #include <string.h>
#include <limits.h>
#include "zdtmtst.h" #include "zdtmtst.h"
const char *test_doc = "Check pending signals"; const char *test_doc = "Check pending signals";
...@@ -86,7 +88,7 @@ static int thread_id; ...@@ -86,7 +88,7 @@ static int thread_id;
static void *thread_fn(void *args) static void *thread_fn(void *args)
{ {
sigset_t blockmask; sigset_t blockmask, oldset, newset;
struct sigaction act; struct sigaction act;
sigfillset(&blockmask); sigfillset(&blockmask);
...@@ -97,6 +99,11 @@ static void *thread_fn(void *args) ...@@ -97,6 +99,11 @@ static void *thread_fn(void *args)
return NULL; return NULL;
} }
if (sigprocmask(SIG_BLOCK, NULL, &oldset) == -1) {
err("sigprocmask");
return NULL;
}
thread_id = syscall(SYS_gettid); thread_id = syscall(SYS_gettid);
act.sa_flags = SA_SIGINFO | SA_RESTART; act.sa_flags = SA_SIGINFO | SA_RESTART;
...@@ -113,11 +120,16 @@ static void *thread_fn(void *args) ...@@ -113,11 +120,16 @@ static void *thread_fn(void *args)
pthread_mutex_unlock(&init_lock); pthread_mutex_unlock(&init_lock);
pthread_mutex_lock(&exit_lock); pthread_mutex_lock(&exit_lock);
if (sigprocmask(SIG_UNBLOCK, &blockmask, NULL) == -1) { if (sigprocmask(SIG_UNBLOCK, &blockmask, &newset) == -1) {
err("sigprocmask"); err("sigprocmask");
return NULL; return NULL;
} }
if (!memcmp(&newset, &oldset, sizeof(newset))) {
fail("The signal blocking mask was changed");
numsig = INT_MAX;
}
return NULL; return NULL;
} }
...@@ -144,7 +156,7 @@ int send_siginfo(int signo, pid_t pid, pid_t tid, int group, siginfo_t *info) ...@@ -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) int main(int argc, char ** argv)
{ {
sigset_t blockmask; sigset_t blockmask, oldset, newset;
struct sigaction act; struct sigaction act;
pthread_t pthrd; pthread_t pthrd;
int i; int i;
...@@ -170,6 +182,11 @@ int main(int argc, char ** argv) ...@@ -170,6 +182,11 @@ int main(int argc, char ** argv)
return -1; return -1;
} }
if (sigprocmask(SIG_BLOCK, &oldset, NULL) == -1) {
err("sigprocmask");
return -1;
}
child = fork(); child = fork();
if (child == -1) { if (child == -1) {
err("fork"); err("fork");
...@@ -218,13 +235,18 @@ int main(int argc, char ** argv) ...@@ -218,13 +235,18 @@ int main(int argc, char ** argv)
test_waitsig(); test_waitsig();
if (sigprocmask(SIG_UNBLOCK, &blockmask, NULL) == -1) { if (sigprocmask(SIG_UNBLOCK, &blockmask, &newset) == -1) {
err("sigprocmask"); err("sigprocmask");
return -1; return -1;
} }
pthread_mutex_unlock(&exit_lock); pthread_mutex_unlock(&exit_lock);
pthread_join(pthrd, NULL); pthread_join(pthrd, NULL);
if (!memcmp(&newset, &oldset, sizeof(newset))) {
fail("The signal blocking mask was changed");
return 1;
}
if (numsig == sent_sigs) if (numsig == sent_sigs)
pass(); pass();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment