From 1d323283d6d32f0c5eb4e882a084419ba3e77d14 Mon Sep 17 00:00:00 2001 From: milahu Date: Wed, 23 Apr 2025 12:06:26 +0200 Subject: [PATCH] FIXME false positive error: Our tor binary is still in use... giving up --- .../kotlin/org/berndpruenster/netlayer/tor/TorContext.kt | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tor.native/src/main/kotlin/org/berndpruenster/netlayer/tor/TorContext.kt b/tor.native/src/main/kotlin/org/berndpruenster/netlayer/tor/TorContext.kt index 15c7845..9959630 100644 --- a/tor.native/src/main/kotlin/org/berndpruenster/netlayer/tor/TorContext.kt +++ b/tor.native/src/main/kotlin/org/berndpruenster/netlayer/tor/TorContext.kt @@ -181,8 +181,12 @@ abstract class TorContext @Throws(IOException::class) protected constructor(val // getRuntime: Returns the runtime object associated with the current Java application. // exec: Executes the specified string command in a separate process. - val p = Runtime.getRuntime().exec(if (OsType.current.isUnixoid()) "ps -few" else (System.getenv("windir") + "\\system32\\" + "tasklist.exe /fo csv /nh")) + // FIXME this can return false positive matches + // $ ps -few | grep /home/user/.local/share/Haveno/xmr_mainnet/tor/tor | grep -v grep + // user 678217 195492 0 08:41 pts/21 00:00:00 nano /home/user/.local/share/Haveno/xmr_mainnet/tor/torrc + val p = Runtime.getRuntime().exec(if (OsType.current.isUnixoid()) "ps -eo args" else (System.getenv("windir") + "\\system32\\" + "tasklist.exe /fo csv /nh")) val allText = p.inputStream.bufferedReader().use(BufferedReader::readText) + // FIXME use regex: (^|\n)/path/to/tor( |\n|$) if (!allText.contains(torExecutableFile.absolutePath)) break