Suppress EBADF for RootServer as well
This commit is contained in:
@@ -303,8 +303,7 @@ class RootServer {
|
||||
output.close()
|
||||
process.outputStream.close()
|
||||
} catch (e: IOException) {
|
||||
// Stream closed caused in NullOutputStream
|
||||
if (e.message != "Stream closed") Logger.me.w("send Shutdown failed", e)
|
||||
if (!e.isEBADF) Logger.me.w("send Shutdown failed", e)
|
||||
}
|
||||
Logger.me.d("Client closed")
|
||||
}
|
||||
|
||||
@@ -6,9 +6,12 @@ import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.os.Parcel
|
||||
import android.os.Parcelable
|
||||
import android.system.ErrnoException
|
||||
import android.system.OsConstants
|
||||
import android.util.*
|
||||
import androidx.annotation.RequiresApi
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import java.io.IOException
|
||||
|
||||
class NoShellException(cause: Throwable) : Exception("Root missing", cause)
|
||||
|
||||
@@ -247,3 +250,6 @@ inline fun <reified T : Parcelable> ByteArray.toParcelable(classLoader: ClassLoa
|
||||
p.setDataPosition(0)
|
||||
p.readParcelable<T>(classLoader)
|
||||
}
|
||||
|
||||
// Stream closed caused in NullOutputStream
|
||||
val IOException.isEBADF get() = message == "Stream closed" || (cause as? ErrnoException)?.errno == OsConstants.EBADF
|
||||
|
||||
@@ -1,10 +1,9 @@
|
||||
package be.mygod.vpnhotspot.net.monitor
|
||||
|
||||
import android.os.Build
|
||||
import android.system.ErrnoException
|
||||
import android.system.OsConstants
|
||||
import androidx.core.content.edit
|
||||
import be.mygod.librootkotlinx.RootServer
|
||||
import be.mygod.librootkotlinx.isEBADF
|
||||
import be.mygod.vpnhotspot.App.Companion.app
|
||||
import be.mygod.vpnhotspot.BuildConfig
|
||||
import be.mygod.vpnhotspot.R
|
||||
@@ -70,9 +69,7 @@ abstract class IpMonitor {
|
||||
try {
|
||||
process.errorStream.bufferedReader().forEachLine { Timber.e(it) }
|
||||
} catch (_: InterruptedIOException) { } catch (e: IOException) {
|
||||
if ((e.cause as? ErrnoException)?.errno != OsConstants.EBADF && e.message != "Stream closed") {
|
||||
Timber.w(e)
|
||||
}
|
||||
if (!e.isEBADF) Timber.w(e)
|
||||
}
|
||||
}
|
||||
try {
|
||||
@@ -83,7 +80,7 @@ abstract class IpMonitor {
|
||||
} else processLine(it)
|
||||
}
|
||||
} catch (_: InterruptedIOException) { } catch (e: IOException) {
|
||||
if ((e.cause as? ErrnoException)?.errno != OsConstants.EBADF && e.message != "Stream closed") Timber.w(e)
|
||||
if (!e.isEBADF) Timber.w(e)
|
||||
}
|
||||
err.join()
|
||||
Timber.d("Monitor process exited with ${process.waitFor()}")
|
||||
|
||||
Reference in New Issue
Block a user