Wait for process to terminate with a better way

Refine #1122.
This commit is contained in:
Mygod
2017-03-01 22:28:35 +08:00
parent b6667b9e0f
commit 86773085c3
3 changed files with 35 additions and 19 deletions
@@ -115,12 +115,7 @@ class GuardedProcess(cmd: String*) {
private def destroyProcess() {
if (Build.VERSION.SDK_INT < 24) {
JniHelper.sigtermCompat(process)
var tries = 0
while (JniHelper.waitpidCompat(process) == 0 && tries < 3) {
Log.w(TAG, "still waiting for process " + Commandline.toString(cmd))
Thread.sleep(200)
tries += 1
}
JniHelper.waitForCompat(process, 500)
}
process.destroy()
}