Commit 084a630d authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

zdtm: use a current stack for preccesses created by clone()

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 9a726d4f
...@@ -204,9 +204,11 @@ void test_init(int argc, char **argv) ...@@ -204,9 +204,11 @@ void test_init(int argc, char **argv)
srand48(time(NULL)); /* just in case we need it */ srand48(time(NULL)); /* just in case we need it */
} }
#define STACK_SIZE (8 * 4096) #define STACK_SIZE 4096
struct zdtm_clone_arg { struct zdtm_clone_arg {
char stack[STACK_SIZE];
char stack_ptr[0];
FILE *pidf; FILE *pidf;
int argc; int argc;
char **argv; char **argv;
...@@ -256,7 +258,6 @@ void test_init_ns(int argc, char **argv, unsigned long clone_flags, ...@@ -256,7 +258,6 @@ void test_init_ns(int argc, char **argv, unsigned long clone_flags,
.sa_flags = SA_RESTART, .sa_flags = SA_RESTART,
}; };
struct zdtm_clone_arg ca; struct zdtm_clone_arg ca;
void *stack;
sigemptyset(&sa.sa_mask); sigemptyset(&sa.sa_mask);
...@@ -283,18 +284,11 @@ void test_init_ns(int argc, char **argv, unsigned long clone_flags, ...@@ -283,18 +284,11 @@ void test_init_ns(int argc, char **argv, unsigned long clone_flags,
exit(1); exit(1);
} }
stack = mmap(NULL, STACK_SIZE, PROT_WRITE | PROT_READ,
MAP_PRIVATE | MAP_GROWSDOWN | MAP_ANONYMOUS, -1, 0);
if (stack == MAP_FAILED) {
err("Can't map stack\n");
exit(1);
}
ca.pidf = pidf; ca.pidf = pidf;
ca.fn = fn; ca.fn = fn;
ca.argc = argc; ca.argc = argc;
ca.argv = argv; ca.argv = argv;
pid = clone(do_test_fn, stack + STACK_SIZE, clone_flags | SIGCHLD, &ca); pid = clone(do_test_fn, ca.stack_ptr, clone_flags | SIGCHLD, &ca);
if (pid < 0) { if (pid < 0) {
err("Daemonizing failed: %m\n"); err("Daemonizing failed: %m\n");
exit(1); exit(1);
......
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