[tor-commits] [stem/master] Making get_process_name()'s ps lookup work on OSX

atagar at torproject.org atagar at torproject.org
Mon Feb 18 04:40:22 UTC 2013


commit bdbb508ae2ffcaa5480992d33c28ec52a6e61b7e
Author: Damian Johnson <atagar at torproject.org>
Date:   Sun Feb 17 20:34:11 2013 -0800

    Making get_process_name()'s ps lookup work on OSX
    
    The get_process_name() function uses a couple approaches to determine our
    process name, the first being to query ps. This tends to work pretty well
    across various platforms (barring Windows, of course), but there's a slight
    difference in the header on OSX/BSD. Accounting for this...
    
    Example ps output:
    
    stem git:(master) : ps -p 60437 -o args
    ARGS
    tor --socksport 9050
    
    Caught by Sathyanarayanan on...
    
    https://trac.torproject.org/8266
---
 stem/util/system.py |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/stem/util/system.py b/stem/util/system.py
index 46aead2..0a42881 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -707,7 +707,7 @@ def get_process_name():
 
     ps_output = call("ps -p %i -o args" % os.getpid(), [])
 
-    if len(ps_output) == 2 and ps_output[0] == "COMMAND":
+    if len(ps_output) == 2 and ps_output[0] in ("COMMAND", "ARGS"):
       _PROCESS_NAME = ps_output[1]
     else:
       # Falling back on using ctypes to get our argv. Unfortunately the simple



More information about the tor-commits mailing list