mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 00:58:31 +00:00
zdtm: check signal blocking mask in static/sigpending
Signed-off-by: Andrey Vagin <avagin@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
parent
ae729638ef
commit
83d4ceb89a
1 changed files with 26 additions and 4 deletions
|
|
@ -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();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue