diff --git a/src/mp/gen.cpp b/src/mp/gen.cpp index 9aba915c..b0239dc1 100644 --- a/src/mp/gen.cpp +++ b/src/mp/gen.cpp @@ -7,10 +7,12 @@ #include #include +#include #include #include #include #include +#include #include #include @@ -137,6 +139,9 @@ void Generate(kj::StringPtr src_prefix, args.emplace_back("--output=" capnp_PREFIX "/bin/capnpc-c++"); args.emplace_back(src_file); int pid = fork(); + if (pid == -1) { + throw std::system_error(errno, std::system_category(), "fork"); + } if (!pid) { mp::ExecProcess(args); } diff --git a/src/mp/util.cpp b/src/mp/util.cpp index 79b2287e..c3be76bb 100644 --- a/src/mp/util.cpp +++ b/src/mp/util.cpp @@ -4,6 +4,7 @@ #include +#include #include #include #include @@ -13,6 +14,7 @@ #include #include #include +#include #include #if __linux__ @@ -83,6 +85,9 @@ int SpawnProcess(int& pid, FdToArgsFn&& fd_to_args) } pid = fork(); + if (pid == -1) { + throw std::system_error(errno, std::system_category(), "fork"); + } if (close(fds[pid ? 0 : 1]) != 0) { throw std::system_error(errno, std::system_category()); }