* to complete, returning the exit status.
*
* A thread-safe [1] version of popen() (type="r", to read from the child):
- * Subprocess proc(cmd, Subprocess::pipeStdout());
+ * Subprocess proc(cmd, Subprocess::Options().pipeStdout());
* // read from proc.stdoutFd()
* proc.wait();
*
* A thread-safe [1] version of popen() (type="w", to write to the child):
- * Subprocess proc(cmd, Subprocess::pipeStdin());
+ * Subprocess proc(cmd, Subprocess::Options().pipeStdin());
* // write to proc.stdinFd()
* proc.wait();
*
#include <folly/Range.h>
#include <folly/gen/String.h>
#include <folly/io/IOBufQueue.h>
+#include <folly/portability/SysResource.h>
namespace folly {
class CalledProcessError : public SubprocessError {
public:
explicit CalledProcessError(ProcessReturnCode rc);
- ~CalledProcessError() throw() = default;
+ ~CalledProcessError() throw() override = default;
const char* what() const throw() override { return what_.c_str(); }
ProcessReturnCode returnCode() const { return returnCode_; }
private:
class SubprocessSpawnError : public SubprocessError {
public:
SubprocessSpawnError(const char* executable, int errCode, int errnoValue);
- ~SubprocessSpawnError() throw() = default;
+ ~SubprocessSpawnError() throw() override = default;
const char* what() const throw() override { return what_.c_str(); }
int errnoValue() const { return errnoValue_; }
#endif
};
- static Options pipeStdin() { return Options().stdinFd(PIPE); }
- static Options pipeStdout() { return Options().stdoutFd(PIPE); }
- static Options pipeStderr() { return Options().stderrFd(PIPE); }
-
// Non-copiable, but movable
Subprocess(const Subprocess&) = delete;
Subprocess& operator=(const Subprocess&) = delete;
* 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.