summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamian Johnson <atagar@torproject.org>2016-10-29 23:00:16 -0700
committerDamian Johnson <atagar@torproject.org>2016-10-29 23:00:16 -0700
commitdc9b874bdc8bcf5556ba8a03e98beb50221fae41 (patch)
treeef62b776074e0e3060ab9d49c92c34d5eb907e2a
parentaec24a2c3ca5bf74dec3b1390e4dd69a93972028 (diff)
Occasional failure of cwd() on OSX
Interesting. Teor ran into an issue due to lsof returning three (rather than the expected two) values on OSX... https://trac.torproject.org/projects/tor/ticket/20477 Not quite sure why but meh, easy to fix.
-rw-r--r--stem/util/system.py4
-rw-r--r--test/unit/util/system.py1
2 files changed, 3 insertions, 2 deletions
diff --git a/stem/util/system.py b/stem/util/system.py
index 77980481..600ab49a 100644
--- a/stem/util/system.py
+++ b/stem/util/system.py
@@ -737,8 +737,8 @@ def cwd(pid):
if is_available('lsof'):
results = call(GET_CWD_LSOF % pid, [])
- if len(results) == 2 and results[1].startswith('n/'):
- lsof_result = results[1][1:].strip()
+ if len(results) >= 2 and results[-1].startswith('n/'):
+ lsof_result = results[-1][1:].strip()
# If we lack read permissions for the cwd then it returns...
# p2683
diff --git a/test/unit/util/system.py b/test/unit/util/system.py
index 0bb59f39..509b9cb3 100644
--- a/test/unit/util/system.py
+++ b/test/unit/util/system.py
@@ -362,6 +362,7 @@ class TestSystem(unittest.TestCase):
responses = {
'75717': ['p75717', 'n/Users/atagar/tor/src/or'],
+ '75717': ['p75717', 'fcwd', 'n/Users/atagar/tor/src/or'],
'1234': ['malformed output'],
'7878': [],
}