projects
/
folly.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
unwrapTryTuple only accepted rvalue tuple types
[folly.git]
/
folly
/
Subprocess.h
diff --git
a/folly/Subprocess.h
b/folly/Subprocess.h
index d739288a1c49b73aded1a4679d54009ed534c048..042a1b9b91f08262c2a88ac6f6aa394f18c04f8e 100644
(file)
--- a/
folly/Subprocess.h
+++ b/
folly/Subprocess.h
@@
-33,12
+33,12
@@
* to complete, returning the exit status.
*
* A thread-safe [1] version of popen() (type="r", to read from the child):
* 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):
* // 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();
*
* // write to proc.stdinFd()
* proc.wait();
*
@@
-93,8
+93,9
@@
#pragma once
#pragma once
-#include <sys/types.h>
#include <signal.h>
#include <signal.h>
+#include <sys/types.h>
+
#if __APPLE__
#include <sys/wait.h>
#else
#if __APPLE__
#include <sys/wait.h>
#else
@@
-102,8
+103,8
@@
#endif
#include <exception>
#endif
#include <exception>
-#include <vector>
#include <string>
#include <string>
+#include <vector>
#include <boost/container/flat_map.hpp>
#include <boost/container/flat_map.hpp>
@@
-117,6
+118,7
@@
#include <folly/Range.h>
#include <folly/gen/String.h>
#include <folly/io/IOBufQueue.h>
#include <folly/Range.h>
#include <folly/gen/String.h>
#include <folly/io/IOBufQueue.h>
+#include <folly/portability/SysResource.h>
namespace folly {
namespace folly {
@@
-208,7
+210,10
@@
class ProcessReturnCode {
/**
* Base exception thrown by the Subprocess methods.
*/
/**
* Base exception thrown by the Subprocess methods.
*/
-class SubprocessError : public std::exception {};
+class SubprocessError : public std::runtime_error {
+ public:
+ using std::runtime_error::runtime_error;
+};
/**
* Exception thrown by *Checked methods of Subprocess.
/**
* Exception thrown by *Checked methods of Subprocess.
@@
-216,12
+221,10
@@
class SubprocessError : public std::exception {};
class CalledProcessError : public SubprocessError {
public:
explicit CalledProcessError(ProcessReturnCode rc);
class CalledProcessError : public SubprocessError {
public:
explicit CalledProcessError(ProcessReturnCode rc);
- ~CalledProcessError() throw() = default;
- const char* what() const throw() override { return what_.c_str(); }
+ ~CalledProcessError() throw() override = default;
ProcessReturnCode returnCode() const { return returnCode_; }
private:
ProcessReturnCode returnCode_;
ProcessReturnCode returnCode() const { return returnCode_; }
private:
ProcessReturnCode returnCode_;
- std::string what_;
};
/**
};
/**
@@
-230,13
+233,11
@@
class CalledProcessError : public SubprocessError {
class SubprocessSpawnError : public SubprocessError {
public:
SubprocessSpawnError(const char* executable, int errCode, int errnoValue);
class SubprocessSpawnError : public SubprocessError {
public:
SubprocessSpawnError(const char* executable, int errCode, int errnoValue);
- ~SubprocessSpawnError() throw() = default;
- const char* what() const throw() override { return what_.c_str(); }
+ ~SubprocessSpawnError() throw() override = default;
int errnoValue() const { return errnoValue_; }
private:
int errnoValue_;
int errnoValue() const { return errnoValue_; }
private:
int errnoValue_;
- std::string what_;
};
/**
};
/**
@@
-439,10
+440,6
@@
class Subprocess {
#endif
};
#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;
// Non-copiable, but movable
Subprocess(const Subprocess&) = delete;
Subprocess& operator=(const Subprocess&) = delete;
@@
-513,7
+510,7
@@
class Subprocess {
* e.g. if you wait for the underlying process without going through this
* Subprocess instance.
*/
* 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.
/**
* Poll the child's status. If the process is still running, return false.
@@
-885,4
+882,4
@@
class Subprocess {
std::vector<Pipe> pipes_;
};
std::vector<Pipe> pipes_;
};
-}
// namespace folly
+} // namespace folly