#if __linux__
#include <sys/prctl.h>
-#include <sys/syscall.h>
-#include <unistd.h>
#endif
#include <fcntl.h>
#include <folly/io/Cursor.h>
#include <folly/portability/Sockets.h>
#include <folly/portability/Stdlib.h>
+#include <folly/portability/SysSyscall.h>
#include <folly/portability/Unistd.h>
constexpr int kExecFailure = 127;
throw SubprocessSpawnError(executable, info.errCode, info.errnoValue);
}
-ProcessReturnCode Subprocess::poll() {
+ProcessReturnCode Subprocess::poll(struct rusage* ru) {
returnCode_.enforce(ProcessReturnCode::RUNNING);
DCHECK_GT(pid_, 0);
int status;
- pid_t found = ::waitpid(pid_, &status, WNOHANG);
+ pid_t found = ::wait4(pid_, &status, WNOHANG, ru);
// The spec guarantees that EINTR does not occur with WNOHANG, so the only
// two remaining errors are ECHILD (other code reaped the child?), or
// EINVAL (cosmic rays?), both of which merit an abort:
#include <folly/Range.h>
#include <folly/gen/String.h>
#include <folly/io/IOBufQueue.h>
+#include <folly/portability/SysResource.h>
namespace folly {
* e.g. if you wait for the underlying process without going through this
* Subprocess instance.
*/
- ProcessReturnCode poll();
+ ProcessReturnCode poll(struct rusage* ru = nullptr);
/**
* Poll the child's status. If the process is still running, return false.