summaryrefslogtreecommitdiff
path: root/runtime/exec_utils.h
diff options
context:
space:
mode:
author Orion Hodson <oth@google.com> 2021-01-15 16:31:30 +0000
committer Treehugger Robot <treehugger-gerrit@google.com> 2021-01-18 11:19:44 +0000
commitdd732cc38f57844bfcedc5687d4b66df7102f31f (patch)
tree91f9d8fcf1bdf4778e994ab4acadbb0f23b7c278 /runtime/exec_utils.h
parent748e9564c5334834aee0050533e6f1d24557f8c9 (diff)
Add an overload of ExecAndReturnCode taking a timeout
Enables callers to timeout waiting on a subprocess. Bug: 177432913 Test: test-art-host-gtest-art_runtime_tests32 Change-Id: I7a27e0ca4679f45daf815d7e2563ca9b723bd701
Diffstat (limited to 'runtime/exec_utils.h')
-rw-r--r--runtime/exec_utils.h14
1 files changed, 11 insertions, 3 deletions
diff --git a/runtime/exec_utils.h b/runtime/exec_utils.h
index 093f7b8d80..5e22639a08 100644
--- a/runtime/exec_utils.h
+++ b/runtime/exec_utils.h
@@ -23,11 +23,19 @@
namespace art {
// Wrapper on fork/execv to run a command in a subprocess.
-// Both of these spawn child processes using the environment as it was set when the single instance
+// These spawn child processes using the environment as it was set when the single instance
// of the runtime (Runtime::Current()) was started. If no instance of the runtime was started, it
// will use the current environment settings.
-bool Exec(std::vector<std::string>& arg_vector, std::string* error_msg);
-int ExecAndReturnCode(std::vector<std::string>& arg_vector, std::string* error_msg);
+
+bool Exec(std::vector<std::string>& arg_vector, /*out*/ std::string* error_msg);
+int ExecAndReturnCode(std::vector<std::string>& arg_vector, /*out*/ std::string* error_msg);
+
+// Execute the command specified in `argv_vector` in a subprocess with a timeout.
+// Returns the process exit code on success, -1 otherwise.
+int ExecAndReturnCode(std::vector<std::string>& arg_vector,
+ time_t timeout_secs,
+ /*out*/ bool* timed_out,
+ /*out*/ std::string* error_msg);
} // namespace art