diff --git a/tools/makeparallel/makeparallel.cpp b/tools/makeparallel/makeparallel.cpp index 3c39846ec..c70fa9a78 100644 --- a/tools/makeparallel/makeparallel.cpp +++ b/tools/makeparallel/makeparallel.cpp @@ -26,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -343,6 +344,15 @@ int main(int argc, char* argv[]) { // child unsetenv("MAKEFLAGS"); unsetenv("MAKELEVEL"); + + // make 3.81 sets the stack ulimit to unlimited, which may cause problems + // for child processes + struct rlimit rlim{}; + if (getrlimit(RLIMIT_STACK, &rlim) == 0 && rlim.rlim_cur == RLIM_INFINITY) { + rlim.rlim_cur = 8*1024*1024; + setrlimit(RLIMIT_STACK, &rlim); + } + int ret = execvp(path, args.data()); if (ret < 0) { error(errno, errno, "exec %s failed", path);