Merge "debuggerd_handler: don't use waitpid(..., __WCLONE)." am: c2467e03ce am: 6579e50ee5 am: 78cb6864c8

am: 286da17554

Change-Id: I15057e1c856c1948b46d6dac8605e28e75269102
This commit is contained in:
Josh Gao 2017-02-14 03:09:18 +00:00 committed by android-build-merger
commit f73e77953c
2 changed files with 33 additions and 1 deletions

View file

@ -407,3 +407,35 @@ TEST_F(CrasherTest, PR_SET_DUMPABLE_0_raise) {
});
AssertDeath(SIGUSR1);
}
TEST(crash_dump, zombie) {
pid_t forkpid = fork();
int pipefd[2];
ASSERT_EQ(0, pipe2(pipefd, O_CLOEXEC));
pid_t rc;
int status;
if (forkpid == 0) {
errno = 0;
rc = waitpid(-1, &status, WNOHANG | __WALL | __WNOTHREAD);
if (rc != -1 || errno != ECHILD) {
errx(2, "first waitpid returned %d (%s), expected failure with ECHILD", rc, strerror(errno));
}
raise(DEBUGGER_SIGNAL);
errno = 0;
rc = waitpid(-1, &status, __WALL | __WNOTHREAD);
if (rc != -1 || errno != ECHILD) {
errx(2, "second waitpid returned %d (%s), expected failure with ECHILD", rc, strerror(errno));
}
_exit(0);
} else {
rc = waitpid(forkpid, &status, 0);
ASSERT_EQ(forkpid, rc);
ASSERT_TRUE(WIFEXITED(status));
ASSERT_EQ(0, WEXITSTATUS(status));
}
}

View file

@ -249,7 +249,7 @@ static int debuggerd_dispatch_pseudothread(void* arg) {
// Don't leave a zombie child.
int status;
if (TEMP_FAILURE_RETRY(waitpid(forkpid, &status, __WCLONE)) == -1 && errno != ECHILD) {
if (TEMP_FAILURE_RETRY(waitpid(forkpid, &status, 0)) == -1) {
__libc_format_log(ANDROID_LOG_FATAL, "libc", "failed to wait for crash_dump helper: %s",
strerror(errno));
} else if (WIFSTOPPED(status) || WIFSIGNALED(status)) {