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 @@
#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();
......
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