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

[tor-commits] [stem/master] Occasional failure of cwd() on OSX



commit dc9b874bdc8bcf5556ba8a03e98beb50221fae41
Author: Damian Johnson <atagar@xxxxxxxxxxxxxx>
Date:   Sat Oct 29 23:00:16 2016 -0700

    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.
---
 stem/util/system.py      | 4 ++--
 test/unit/util/system.py | 1 +
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/stem/util/system.py b/stem/util/system.py
index 7798048..600ab49 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 0bb59f3..509b9cb 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': [],
     }

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