Commit 0046ed87 authored by Mygod's avatar Mygod

Fix a crash on Android 6.0

parent 4f44d119
......@@ -25,6 +25,7 @@ import android.util.Log
import com.github.shadowsocks.App.Companion.app
import com.github.shadowsocks.JniHelper
import java.io.File
import java.io.FileNotFoundException
object Executable {
const val REDSOCKS = "libredsocks.so"
......@@ -37,7 +38,11 @@ object Executable {
fun killAll() {
for (process in File("/proc").listFiles { _, name -> TextUtils.isDigitsOnly(name) }) {
val exe = File(File(process, "cmdline").readText().split(Character.MIN_VALUE, limit = 2).first())
val exe = File(try {
File(process, "cmdline").readText()
} catch (ignore: FileNotFoundException) {
continue
}.split(Character.MIN_VALUE, limit = 2).first())
if (exe.parent == app.applicationInfo.nativeLibraryDir && EXECUTABLES.contains(exe.name)) {
val errno = JniHelper.sigkill(process.name.toInt())
if (errno != 0) Log.w("kill", "SIGKILL ${exe.absolutePath} (${process.name}) failed with $errno")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment