diff options
| author | 2016-08-04 20:05:17 +0000 | |
|---|---|---|
| committer | 2016-08-04 20:05:17 +0000 | |
| commit | 960bd196fa9b767250e584f09e81eec3f5d23e8b (patch) | |
| tree | e6e527979a689b64fe6f44eb44177fd1a55f618c | |
| parent | 25dd953085f0c35a395bde468251c2b13e944282 (diff) | |
| parent | da820e97bbe7f0a2f06060d8766bc03341904f40 (diff) | |
Merge "Clean up use of art::Exec versus execv."
| -rw-r--r-- | oatdump/oatdump_test.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/oatdump/oatdump_test.cc b/oatdump/oatdump_test.cc index 63dc476560..db970556e6 100644 --- a/oatdump/oatdump_test.cc +++ b/oatdump/oatdump_test.cc @@ -104,11 +104,13 @@ class OatDumpTest : public CommonRuntimeTest { // We must set --android-root. int link[2]; if (pipe(link) == -1) { + *error_msg = strerror(errno); return false; } const pid_t pid = fork(); if (pid == -1) { + *error_msg = strerror(errno); return false; } @@ -116,10 +118,19 @@ class OatDumpTest : public CommonRuntimeTest { dup2(link[1], STDOUT_FILENO); close(link[0]); close(link[1]); - bool res = ::art::Exec(exec_argv, error_msg); - // Delete the runtime to prevent memory leaks and please valgrind. - delete Runtime::Current(); - exit(res ? 0 : 1); + // change process groups, so we don't get reaped by ProcessManager + setpgid(0, 0); + // Use execv here rather than art::Exec to avoid blocking on waitpid here. + std::vector<char*> argv; + for (size_t i = 0; i < exec_argv.size(); ++i) { + argv.push_back(const_cast<char*>(exec_argv[i].c_str())); + } + argv.push_back(nullptr); + UNUSED(execv(argv[0], &argv[0])); + const std::string command_line(Join(exec_argv, ' ')); + PLOG(ERROR) << "Failed to execv(" << command_line << ")"; + // _exit to avoid atexit handlers in child. + _exit(1); } else { close(link[1]); static const size_t kLineMax = 256; |