Commit 5a15f730 authored by Mygod's avatar Mygod

Fix Executable.killAll

parent e3e99adc
...@@ -26,7 +26,6 @@ import android.system.OsConstants ...@@ -26,7 +26,6 @@ import android.system.OsConstants
import android.text.TextUtils import android.text.TextUtils
import android.util.Log import android.util.Log
import com.crashlytics.android.Crashlytics import com.crashlytics.android.Crashlytics
import com.github.shadowsocks.Core.app
import java.io.File import java.io.File
import java.io.FileNotFoundException import java.io.FileNotFoundException
...@@ -40,11 +39,11 @@ object Executable { ...@@ -40,11 +39,11 @@ object Executable {
fun killAll() { fun killAll() {
for (process in File("/proc").listFiles { _, name -> TextUtils.isDigitsOnly(name) }) { for (process in File("/proc").listFiles { _, name -> TextUtils.isDigitsOnly(name) }) {
val exe = File(try { val exe = File(try {
File(process, "cmdline").readText() File(process, "cmdline").inputStream().bufferedReader().readText()
} catch (ignore: FileNotFoundException) { } catch (_: FileNotFoundException) {
continue continue
}.split(Character.MIN_VALUE, limit = 2).first()) }.split(Character.MIN_VALUE, limit = 2).first())
if (exe.parent == app.applicationInfo.nativeLibraryDir && EXECUTABLES.contains(exe.name)) try { if (EXECUTABLES.contains(exe.name)) try {
Os.kill(process.name.toInt(), OsConstants.SIGKILL) Os.kill(process.name.toInt(), OsConstants.SIGKILL)
} catch (e: ErrnoException) { } catch (e: ErrnoException) {
if (e.errno != OsConstants.ESRCH) { if (e.errno != OsConstants.ESRCH) {
......
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