From 717c8ec2f37682a4c8cbbd651f706dee7b3c1e1d Mon Sep 17 00:00:00 2001 From: Micah Lee Date: Tue, 17 Nov 2020 18:46:22 -0800 Subject: [PATCH] Make onionshare tor process detection work in Windows --- cli/onionshare_cli/onion.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cli/onionshare_cli/onion.py b/cli/onionshare_cli/onion.py index 138a6673..1b025bf8 100644 --- a/cli/onionshare_cli/onion.py +++ b/cli/onionshare_cli/onion.py @@ -238,7 +238,7 @@ class Onion(object): # If there is an existing OnionShare tor process, kill it for proc in psutil.process_iter(["pid", "name", "username"]): - if proc.username() == getpass.getuser(): + try: cmdline = proc.cmdline() if ( cmdline[0] == self.tor_path @@ -252,6 +252,9 @@ class Onion(object): ) proc.terminate() proc.wait() + break + except: + pass if self.common.platform == "Windows" or self.common.platform == "Darwin": # Windows doesn't support unix sockets, so it must use a network port.