Fix some issues with some su
This commit is contained in:
@@ -31,7 +31,7 @@ class IpNeighbourMonitor private constructor() {
|
|||||||
val monitor = instance ?: return
|
val monitor = instance ?: return
|
||||||
instance = null
|
instance = null
|
||||||
val process = monitor.monitor
|
val process = monitor.monitor
|
||||||
if (process != null) thread(TAG + "-killer") { process.destroy() }
|
if (process != null) thread("$TAG-killer") { process.destroy() }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -46,13 +46,13 @@ class IpNeighbourMonitor private constructor() {
|
|||||||
private var monitor: Process? = null
|
private var monitor: Process? = null
|
||||||
|
|
||||||
init {
|
init {
|
||||||
thread(TAG + "-input") {
|
thread("$TAG-input") {
|
||||||
// monitor may get rejected by SELinux
|
// monitor may get rejected by SELinux
|
||||||
val monitor = ProcessBuilder("sh", "-c", "ip monitor neigh || su -c ip monitor neigh")
|
val monitor = ProcessBuilder("sh", "-c", "ip monitor neigh || su -c 'ip monitor neigh'")
|
||||||
.redirectErrorStream(true)
|
.redirectErrorStream(true)
|
||||||
.start()
|
.start()
|
||||||
this.monitor = monitor
|
this.monitor = monitor
|
||||||
thread(TAG + "-error") {
|
thread("$TAG-error") {
|
||||||
try {
|
try {
|
||||||
monitor.errorStream.bufferedReader().forEachLine { Log.e(TAG, it) }
|
monitor.errorStream.bufferedReader().forEachLine { Log.e(TAG, it) }
|
||||||
} catch (ignore: InterruptedIOException) { }
|
} catch (ignore: InterruptedIOException) { }
|
||||||
@@ -74,12 +74,12 @@ class IpNeighbourMonitor private constructor() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun flush() = thread(TAG + "-flush") {
|
fun flush() = thread("$TAG-flush") {
|
||||||
val process = ProcessBuilder("ip", "neigh")
|
val process = ProcessBuilder("ip", "neigh")
|
||||||
.redirectErrorStream(true)
|
.redirectErrorStream(true)
|
||||||
.start()
|
.start()
|
||||||
process.waitFor()
|
process.waitFor()
|
||||||
thread(TAG + "-flush-error") {
|
thread("$TAG-flush-error") {
|
||||||
val err = process.errorStream.bufferedReader().readText()
|
val err = process.errorStream.bufferedReader().readText()
|
||||||
if (err.isNotBlank()) {
|
if (err.isNotBlank()) {
|
||||||
Log.e(TAG, err)
|
Log.e(TAG, err)
|
||||||
|
|||||||
Reference in New Issue
Block a user