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

[tor-commits] [stem/master] Fix pids_by_user for FreeBSD



commit f90ef8087d3bd0d95041272480e0554c113942f6
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sun Sep 3 14:39:50 2017 -0700

    Fix pids_by_user for FreeBSD
    
    Turns out FreeBSD uses an uppercase '-U' argument rather than '-u'...
    
      https://trac.torproject.org/projects/tor/ticket/23281#comment:7
---
 stem/util/system.py | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/stem/util/system.py b/stem/util/system.py
index 391c4b70..a563db45 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -129,7 +129,8 @@ GET_PID_BY_PORT_NETSTAT = 'netstat -npltu'
 GET_PID_BY_PORT_SOCKSTAT = 'sockstat -4l -P tcp -p %s'
 GET_PID_BY_PORT_LSOF = 'lsof -wnP -iTCP -sTCP:LISTEN'
 GET_PID_BY_FILE_LSOF = 'lsof -tw %s'
-GET_PIDS_BY_USER = 'ps -o pid -u %s'
+GET_PIDS_BY_USER_LINUX = 'ps -o pid -u %s'
+GET_PIDS_BY_USER_BSD = 'ps -o pid -U %s'
 GET_CWD_PWDX = 'pwdx %s'
 GET_CWD_LSOF = 'lsof -a -p %s -d cwd -Fn'
 GET_BSD_JAIL_ID_PS = 'ps -p %s -o jid'
@@ -861,7 +862,10 @@ def pids_by_user(user):
   #     915
 
   if is_available('ps'):
-    results = call(GET_PIDS_BY_USER % user, None)
+    if is_bsd():
+      results = call(GET_PIDS_BY_USER_BSD % user, None)
+    else:
+      results = call(GET_PIDS_BY_USER_LINUX % user, None)
 
     if results:
       try:

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