[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [stem/master] Unexpected OSError from proc's connections() funciton
commit 3d4825791fd4258eecbc290842d031df8a75fefa
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date: Tue Jan 19 09:43:48 2016 -0800
Unexpected OSError from proc's connections() funciton
We're documented as raising an IOError but our os.listdir() can potentially
raise an exexpected OSError...
Exception in thread Thread-5:
Traceback (most recent call last):
File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner
self.run()
File "/home/pi/nyx/nyx/util/tracker.py", line 382, in run
is_successful = self._task(self._process_pid, self._process_name)
File "/home/pi/nyx/nyx/util/tracker.py", line 503, in _task
for conn in connection.get_connections(resolver, process_pid = process_pid, process_name = process_name):
File "/usr/local/lib/python2.7/dist-packages/stem/util/connection.py", line 195, in get_connections
return [Connection(*conn) for conn in stem.util.proc.connections(process_pid)]
File "/usr/local/lib/python2.7/dist-packages/stem/util/proc.py", line 358, in connections
for fd in os.listdir('/proc/%s/fd' % pid):
OSError: [Errno 13] Permission denied: '/proc/32443/fd'
Caught thanks to Derrick Oswald.
---
stem/util/proc.py | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/stem/util/proc.py b/stem/util/proc.py
index 8093075..5d2219c 100644
--- a/stem/util/proc.py
+++ b/stem/util/proc.py
@@ -355,7 +355,12 @@ def connections(pid):
start_time, parameter = time.time(), 'process connections'
inodes = []
- for fd in os.listdir('/proc/%s/fd' % pid):
+ try:
+ fd_contents = os.listdir('/proc/%s/fd' % pid)
+ except OSError as exc:
+ raise IOError('Unable to read our file descriptors: %s' % exc)
+
+ for fd in fd_contents:
fd_path = '/proc/%s/fd/%s' % (pid, fd)
try:
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits