Log errors from su
This commit is contained in:
@@ -191,6 +191,13 @@ class RootServer @JvmOverloads constructor(private val warnLogger: (String) -> U
|
|||||||
future.completeExceptionally(e)
|
future.completeExceptionally(e)
|
||||||
return@async
|
return@async
|
||||||
}
|
}
|
||||||
|
val errorReader = async(Dispatchers.IO) {
|
||||||
|
try {
|
||||||
|
process.errorStream.bufferedReader().useLines { seq ->
|
||||||
|
for (line in seq) warnLogger(line)
|
||||||
|
}
|
||||||
|
} catch (_: IOException) { }
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
callbackSpin()
|
callbackSpin()
|
||||||
if (active) throw RemoteException("Root process exited unexpectedly")
|
if (active) throw RemoteException("Root process exited unexpectedly")
|
||||||
@@ -199,10 +206,10 @@ class RootServer @JvmOverloads constructor(private val warnLogger: (String) -> U
|
|||||||
throw e
|
throw e
|
||||||
} finally {
|
} finally {
|
||||||
if (DEBUG) Log.d(TAG, "Waiting for exit")
|
if (DEBUG) Log.d(TAG, "Waiting for exit")
|
||||||
|
errorReader.await()
|
||||||
process.waitFor()
|
process.waitFor()
|
||||||
withContext(NonCancellable) { closeInternal(true) }
|
withContext(NonCancellable) { closeInternal(true) }
|
||||||
}
|
}
|
||||||
check(process.errorStream.available() == 0) // stderr should not be used
|
|
||||||
}
|
}
|
||||||
future.await()
|
future.await()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user