diff options
author | 2022-09-09 11:58:56 +0100 | |
---|---|---|
committer | 2022-09-16 20:14:46 +0000 | |
commit | 4c9498e8f1c8ef8c54cfd7462e24a505690cdc10 (patch) | |
tree | 64248e7108103d2e00928f3968b2dc4e98a81082 /runtime/exec_utils.cc | |
parent | 5494695148b63ab33e6e5e178dcef5fa6380116c (diff) |
Change ExecUtils to support callbacks.
artd needs the callbacks to get the pid in order to kill the subprocess.
Partially cherry-picked from
commit 659f49bdb1263ceb26f666052f3ef7e4732b4eb2
Bug: 244412198
Test: m test-art-host-gtest-art_runtime_tests
Merged-In: I8c40949b5ed88ff85ddedad9d86f0b9bbfddb98d
Change-Id: Ia28410bdf6314178756ee5e3a94000dc6f3ecc97
Diffstat (limited to 'runtime/exec_utils.cc')
-rw-r--r-- | runtime/exec_utils.cc | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/runtime/exec_utils.cc b/runtime/exec_utils.cc index cc4667c3a6..929f09f784 100644 --- a/runtime/exec_utils.cc +++ b/runtime/exec_utils.cc @@ -250,11 +250,13 @@ int ExecUtils::ExecAndReturnCode(const std::vector<std::string>& arg_vector, int timeout_sec, bool* timed_out, std::string* error_msg) const { - return ExecAndReturnCode(arg_vector, timeout_sec, timed_out, /*stat=*/nullptr, error_msg); + return ExecAndReturnCode( + arg_vector, timeout_sec, ExecCallbacks(), timed_out, /*stat=*/nullptr, error_msg); } int ExecUtils::ExecAndReturnCode(const std::vector<std::string>& arg_vector, int timeout_sec, + const ExecCallbacks& callbacks, /*out*/ bool* timed_out, /*out*/ ProcessStat* stat, /*out*/ std::string* error_msg) const { @@ -271,6 +273,8 @@ int ExecUtils::ExecAndReturnCode(const std::vector<std::string>& arg_vector, return -1; } + callbacks.on_start(pid); + // Wait for subprocess to finish. int status; if (timeout_sec >= 0) { @@ -295,6 +299,8 @@ int ExecUtils::ExecAndReturnCode(const std::vector<std::string>& arg_vector, } } + callbacks.on_end(pid); + std::string local_error_msg; // TODO(jiakaiz): Use better logic to detect waitid failure. if (WaitChild(pid, arg_vector, /*no_wait=*/false, &local_error_msg) < 0 && |