diff --git a/test/zdtm/live/static/Makefile b/test/zdtm/live/static/Makefile index 67be67555..e66d3ca76 100644 --- a/test/zdtm/live/static/Makefile +++ b/test/zdtm/live/static/Makefile @@ -317,6 +317,7 @@ inotify_system_nodel: override CFLAGS += -DNODEL pthread00: override LDLIBS += -pthread pthread01: override LDLIBS += -pthread pthread02: override LDLIBS += -pthread +different_creds: override LDLIBS += -pthread sigpending: override LDLIBS += -pthread sigaltstack: override LDLIBS += -pthread shm: override CFLAGS += -DNEW_IPC_NS diff --git a/test/zdtm/live/static/different_creds.c b/test/zdtm/live/static/different_creds.c index 545dcb378..c9d23c9d3 100644 --- a/test/zdtm/live/static/different_creds.c +++ b/test/zdtm/live/static/different_creds.c @@ -6,13 +6,18 @@ #include #include #include +#include +#include #include "zdtmtst.h" const char *test_doc = "Check that threads with different creds aren't checkpointed"; const char *test_author = "Tycho Andersen "; -int drop_caps_and_wait(void *arg) +#define exit_group(code) \ + syscall(__NR_exit_group, code) + +void *drop_caps_and_wait(void *arg) { cap_t caps; int *pipe = arg; @@ -20,7 +25,7 @@ int drop_caps_and_wait(void *arg) caps = cap_get_proc(); if (!caps) { err("cap_get_proc"); - return 1; + return NULL; } if (cap_clear_flag(caps, CAP_EFFECTIVE) < 0) { @@ -39,18 +44,14 @@ int drop_caps_and_wait(void *arg) sleep(1000); die: cap_free(caps); - return 1; + return NULL; } int main(int argc, char ** argv) { - pid_t pid; int ret, pipefd[2]; - long clone_flags = CLONE_VM | CLONE_FILES | CLONE_SIGHAND | - CLONE_THREAD | CLONE_SYSVSEM; + pthread_t thr; - size_t stack_size = sysconf(_SC_PAGESIZE); - void *stack = alloca(stack_size); char buf; test_init(argc, argv); @@ -60,12 +61,10 @@ int main(int argc, char ** argv) return -1; } - pid = clone(drop_caps_and_wait, stack + stack_size, clone_flags, pipefd); - if (pid < 0) { - err("fork"); + if (pthread_create(&thr, NULL, drop_caps_and_wait, pipefd)) { + err("Unable to create thread"); return -1; } - close(pipefd[1]); /* @@ -83,6 +82,5 @@ int main(int argc, char ** argv) fail("shouldn't dump successfully"); - kill(pid, SIGKILL); - return ret; + exit_group(ret); }