From 9aec7a2fb6f368922dc9b332ca11fc9d58fcc956 Mon Sep 17 00:00:00 2001 From: Gao Xiang Date: Thu, 7 Dec 2017 11:17:57 +0800 Subject: [PATCH] mFusePid should be cleared after waitpid successfully When waitpid is successful, we need to reset mFusePid since mFusePid will be killed again unnecessarily in doUnmount() if we don't reset mFusePid. As a result, it will kill another unrelated process in the case of pids wrap around. Test: reboot Fixes: 1d79d10 ("Check if sdcard daemon exited.") Change-Id: Icb422d5c81621f9f6b9f4b1218e94b1d89172763 Signed-off-by: Gao Xiang --- EmulatedVolume.cpp | 3 ++- PublicVolume.cpp | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/EmulatedVolume.cpp b/EmulatedVolume.cpp index 21b290a..71eaa3e 100644 --- a/EmulatedVolume.cpp +++ b/EmulatedVolume.cpp @@ -105,7 +105,8 @@ status_t EmulatedVolume::doMount() { usleep(50000); // 50ms } /* sdcardfs will have exited already. FUSE will still be running */ - TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, WNOHANG)); + if (TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, WNOHANG)) == mFusePid) + mFusePid = 0; return OK; } diff --git a/PublicVolume.cpp b/PublicVolume.cpp index f976c4a..4643a3a 100644 --- a/PublicVolume.cpp +++ b/PublicVolume.cpp @@ -191,7 +191,8 @@ status_t PublicVolume::doMount() { usleep(50000); // 50ms } /* sdcardfs will have exited already. FUSE will still be running */ - TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, WNOHANG)); + if (TEMP_FAILURE_RETRY(waitpid(mFusePid, nullptr, WNOHANG)) == mFusePid) + mFusePid = 0; return OK; }