From: Felipe Leme Date: Wed, 23 Mar 2016 23:47:00 +0000 (-0700) Subject: Fixed send_broadcast and fork handling issues. X-Git-Tag: android-x86-7.1-r1~390^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=73f731c30a8b7d811127b8e89e01c427b6aab622;p=android-x86%2Fframeworks-native.git Fixed send_broadcast and fork handling issues. send_broadcast() was calling run_command_always(char*, bool, int, char*) passing: run_command_always(NULL, 20, true, am_args); I.e., it was passing "true" (!1) as the boolean, and 1 (true) as the timeout value; the proper call should be: run_command_always(NULL, true, 20, am_args); Also, the code handling failure on child calls was calling _exit(), which quits dumpstate - it should simply return the function instead. BUG: 27804637 Change-Id: If8c9b40eddc8b76f92e6d11078dfe446a39ad4d4 --- diff --git a/cmds/dumpstate/dumpstate.cpp b/cmds/dumpstate/dumpstate.cpp index 604aea687c..9507ac66c4 100644 --- a/cmds/dumpstate/dumpstate.cpp +++ b/cmds/dumpstate/dumpstate.cpp @@ -200,7 +200,7 @@ static void dump_systrace() { execl("/system/bin/atrace", "/system/bin/atrace", "--async_dump", nullptr); // execl should never return, but it doesn't hurt to handle that scenario MYLOGD("execl on '/system/bin/atrace --async_dump' returned control"); - _exit(-1); + return; } else { close(pipefd[1]); // close the write end of the pipe in the parent add_zip_entry_from_fd("systrace.txt", pipefd[0]); // write output to zip file diff --git a/cmds/dumpstate/utils.cpp b/cmds/dumpstate/utils.cpp index 3fa2141cf1..975cd27b87 100644 --- a/cmds/dumpstate/utils.cpp +++ b/cmds/dumpstate/utils.cpp @@ -723,7 +723,7 @@ int run_command_always(const char *title, bool drop_root, int timeout_seconds, c if (pid == 0) { if (drop_root && !drop_root_user()) { printf("*** could not drop root before running %s: %s\n", command, strerror(errno)); - _exit(-1); + return -1; } /* make sure the child dies when dumpstate dies */ @@ -739,7 +739,7 @@ int run_command_always(const char *title, bool drop_root, int timeout_seconds, c // execvp's result will be handled after waitpid_with_timeout() below... MYLOGD("execvp on command %s returned control (error: %s)", command, strerror(errno)); fflush(stdout); - _exit(-1); // ...but it doesn't hurt to force exit, just in case + return -1; // ...but it doesn't hurt to force exit, just in case } /* handle parent case */ @@ -851,7 +851,7 @@ void send_broadcast(const std::string& action, const std::vector& a std::string args_string; format_args(am_index + 1, am_args, &args_string); MYLOGD("send_broadcast command: %s\n", args_string.c_str()); - run_command_always(NULL, 20, true, am_args); + run_command_always(NULL, true, 20, am_args); } size_t num_props = 0;