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 <gaoxiang25@huawei.com>
diff --git a/EmulatedVolume.cpp b/EmulatedVolume.cpp
index 21b290a..71eaa3e 100644
--- a/EmulatedVolume.cpp
+++ b/EmulatedVolume.cpp
@@ -105,7 +105,8 @@
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;
}