[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Uncaught exception when name_by_pid() fails to call ps
commit efd1c86073ad04ec3c6d79c97dd3db5d3255fdf6
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Sun Sep 7 21:10:35 2014 -0700
Uncaught exception when name_by_pid() fails to call ps
Our name_by_pid() function is documented as returning None if it can't deterine
the process name, but we accidently exposed a possible OSException via our ps
call. Ran into this during arm development...
File "/home/atagar/Desktop/arm/arm/util/tracker.py", line 398, in _tor_status_listener
tor_cmd = system.name_by_pid(tor_pid) if tor_pid else None
File "/home/atagar/Desktop/arm/stem/util/system.py", line 272, in name_by_pid
results = call(GET_NAME_BY_PID_PS % pid)
File "/home/atagar/Desktop/arm/stem/util/system.py", line 921, in call
raise exc
OSError: ps -p 30834 -o comm returned exit status 1
---
stem/util/system.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/stem/util/system.py b/stem/util/system.py
index adfc802..bcd6c0d 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -269,7 +269,10 @@ def name_by_pid(pid):
# vim
if not process_name:
- results = call(GET_NAME_BY_PID_PS % pid)
+ try:
+ results = call(GET_NAME_BY_PID_PS % pid)
+ except OSError:
+ pass
if results and len(results) == 2 and results[0] == 'COMMAND':
process_name = results[1].strip()
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits