[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [arm/master] fix: fixing tor process detection for openbsd



commit 84cd622e515c97d0c9b0d9779204155978926e9d
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Fri Oct 7 09:18:14 2011 -0700

    fix: fixing tor process detection for openbsd
    
    OpenBSD uses a different variant of ps causing the tor process detection (among
    many other things) to fail. Caught thanks to a test system from Jordi Clofent.
---
 src/util/torTools.py |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/src/util/torTools.py b/src/util/torTools.py
index 8e2d6d5..34c9adc 100644
--- a/src/util/torTools.py
+++ b/src/util/torTools.py
@@ -352,6 +352,19 @@ def isTorRunning():
   
   # suggestions welcome for making this more reliable
   commandResults = sysTools.call("ps -A co command")
+  
+  if not commandResults:
+    # OpenBSD uses a weird (and largely broken from the looks of it) version of
+    # ps. It lacks the -A argument and according to the man page -j, -l, and -u
+    # all do something similar but they fail.
+    #
+    # ucomm is defined in the man page as 'Alias: comm.  Name to be used for
+    # accounting.' The alias part is a lie (it works, but with an error
+    # message), though this seems to do what we want and prints the bare
+    # command.
+    
+    commandResults = sysTools.call("ps -o ucomm=")
+  
   if commandResults:
     for cmd in commandResults:
       if cmd.strip() == "tor": return True

_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits