libstore: mmap() returns MAP_FAILED, not NULL on failure

This commit is contained in:
Tuomas Tynkkynen 2015-12-30 00:37:51 +02:00 committed by Eelco Dolstra
parent 71a93a5f0e
commit f770b9e6c5

View file

@ -2175,7 +2175,7 @@ void DerivationGoal::startBuilder()
size_t stackSize = 1 * 1024 * 1024;
char * stack = (char *) mmap(0, stackSize,
PROT_WRITE | PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS | MAP_STACK, -1, 0);
if (!stack) throw SysError("allocating stack");
if (stack == MAP_FAILED) throw SysError("allocating stack");
int flags = CLONE_NEWPID | CLONE_NEWNS | CLONE_NEWIPC | CLONE_NEWUTS | CLONE_PARENT | SIGCHLD;
if (!fixedOutput) flags |= CLONE_NEWNET;
pid_t child = clone(childEntry, stack + stackSize, flags, this);