diff options
author | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-02-23 15:52:04 +0100 |
---|---|---|
committer | Eelco Dolstra <eelco.dolstra@logicblox.com> | 2015-02-23 15:54:31 +0100 |
commit | 885bebf13b619816c0196100accc312c86e0abdf (patch) | |
tree | b97a7e2fdc3fdbf9ac44fd976275cdebfb45df1d /src/libstore | |
parent | 99897f6979aa21339b80904db1717c65a9202110 (diff) |
More graceful fallback for chroots on Linux < 2.13
Diffstat (limited to 'src/libstore')
-rw-r--r-- | src/libstore/build.cc | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/src/libstore/build.cc b/src/libstore/build.cc index ac5ca7bc3..707c416d6 100644 --- a/src/libstore/build.cc +++ b/src/libstore/build.cc @@ -1997,12 +1997,11 @@ void DerivationGoal::startBuilder() int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_PARENT | SIGCHLD; if (!fixedOutput) flags |= CLONE_NEWNET; pid_t child = clone(childEntry, stack + sizeof(stack) - 8, flags, this); - if (child == -1) { - if (errno == EINVAL) - throw SysError("cloning builder process (Linux chroot builds require 3.13 or later)"); - else - throw SysError("cloning builder process"); - } + if (child == -1 && errno == EINVAL) + /* Fallback for Linux < 2.13 where CLONE_NEWPID and + CLONE_PARENT are not allowed together. */ + child = clone(childEntry, stack + sizeof(stack) - 8, flags & ~CLONE_NEWPID, this); + if (child == -1) throw SysError("cloning builder process"); writeFull(builderOut.writeSide, int2String(child) + "\n"); _exit(0); }); |