X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=util-vserver%2Fsrc%2Fnew-namespace.c;h=9d50a30e901223378c68026dc8ac41d933376e16;hb=86a23427cca76a5a9befd60c85535a0e738bc3c6;hp=5684f1e259db581d98a1f4970d60c8d2e2543ad9;hpb=b562f3d09686bb1686646c949b6f92c94eb2d64c;p=util-vserver.git diff --git a/util-vserver/src/new-namespace.c b/util-vserver/src/new-namespace.c index 5684f1e..9d50a30 100644 --- a/util-vserver/src/new-namespace.c +++ b/util-vserver/src/new-namespace.c @@ -25,6 +25,7 @@ #endif #include "util.h" +#include "stack-start.h" #include #include @@ -36,10 +37,16 @@ #include #include +#define ENSC_WRAPPERS_CLONE 1 +#define ENSC_WRAPPERS_WAIT 1 +#include + #ifndef CLONE_NEWNS # define CLONE_NEWNS 0x00020000 #endif +int wrapper_exit_code = 255; + static int childFunc(void *argv_v) { @@ -69,7 +76,8 @@ static void showVersion() { WRITE_MSG(1, - "new-namespace 0.1\n" + "new-namespace " VERSION " -- executes programs in a new namespace\n" + "This program is part of " PACKAGE_STRING "\n" "Copyright (C) 2003 Enrico Scholz\n" VERSION_COPYRIGHT_DISCLAIMER); exit(0); @@ -86,17 +94,12 @@ int main(int argc, char *argv[]) if (!strcmp(argv[1], "--version")) showVersion(); if (!strcmp(argv[1], "--")) ++argv; - pid = clone(childFunc, buf+sizeof(buf)/2, CLONE_NEWNS|CLONE_VFORK|SIGCHLD, argv+1); - if (pid==-1) { - perror("clone()"); - exit(255); - } - - p = wait4(pid, &status, 0,0); - if (p==-1) { - perror("waitpid()"); - exit(255); - } +#ifdef NDEBUG + pid = Eclone(childFunc, STACK_START(buf), CLONE_NEWNS|CLONE_VFORK|SIGCHLD, argv+1); +#else + pid = Eclone(childFunc, STACK_START(buf), CLONE_NEWNS|SIGCHLD, argv+1); +#endif + p = Ewait4(pid, &status, 0,0); if (WIFEXITED(status)) return WEXITSTATUS(status); else return 255;