Commit b3c42b28 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

tests: add a ZDTM_NOREAP variable

We'll use this variable in the next test to make sure the test suite
doesn't accidentally reap the zombie we want to leave around for the actual
test.

This is kind of ugly and there might be a better way to pass information to
the test's init, I'm open for suggestions :)

CC: Andrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Acked-by: 's avatarAndrew Vagin <avagin@virtuozzo.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
parent 67960bbd
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include <grp.h> #include <grp.h>
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <stdbool.h>
#include <sys/mount.h> #include <sys/mount.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/stat.h> #include <sys/stat.h>
...@@ -251,6 +252,7 @@ int ns_init(int argc, char **argv) ...@@ -251,6 +252,7 @@ int ns_init(int argc, char **argv)
int ret, fd, status_pipe = STATUS_FD; int ret, fd, status_pipe = STATUS_FD;
char buf[128], *x; char buf[128], *x;
pid_t pid; pid_t pid;
bool reap;
ret = fcntl(status_pipe, F_SETFD, FD_CLOEXEC); ret = fcntl(status_pipe, F_SETFD, FD_CLOEXEC);
if (ret == -1) { if (ret == -1) {
...@@ -258,9 +260,12 @@ int ns_init(int argc, char **argv) ...@@ -258,9 +260,12 @@ int ns_init(int argc, char **argv)
exit(1); exit(1);
} }
reap = getenv("ZDTM_NOREAP") == NULL;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
sigaddset(&sa.sa_mask, SIGTERM); sigaddset(&sa.sa_mask, SIGTERM);
sigaddset(&sa.sa_mask, SIGCHLD); if (reap)
sigaddset(&sa.sa_mask, SIGCHLD);
if (sigaction(SIGTERM, &sa, NULL)) { if (sigaction(SIGTERM, &sa, NULL)) {
fprintf(stderr, "Can't set SIGTERM handler: %m\n"); fprintf(stderr, "Can't set SIGTERM handler: %m\n");
...@@ -290,12 +295,12 @@ int ns_init(int argc, char **argv) ...@@ -290,12 +295,12 @@ int ns_init(int argc, char **argv)
show_ps(); show_ps();
if (sigaction(SIGCHLD, &sa, NULL)) { if (reap && sigaction(SIGCHLD, &sa, NULL)) {
fprintf(stderr, "Can't set SIGCHLD handler: %m\n"); fprintf(stderr, "Can't set SIGCHLD handler: %m\n");
exit(1); exit(1);
} }
while (1) { while (reap && 1) {
int status; int status;
pid = waitpid(-1, &status, WNOHANG); pid = waitpid(-1, &status, WNOHANG);
......
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