summaryrefslogtreecommitdiff
path: root/Utility
diff options
context:
space:
mode:
Diffstat (limited to 'Utility')
-rw-r--r--Utility/Lsof.hs14
1 files changed, 9 insertions, 5 deletions
diff --git a/Utility/Lsof.hs b/Utility/Lsof.hs
index e44d13197..ae74b25fd 100644
--- a/Utility/Lsof.hs
+++ b/Utility/Lsof.hs
@@ -93,11 +93,15 @@ parseFormatted s = bundle $ go [] $ lines s
_ -> parsefail
parsefiles c [] = (c, [])
- parsefiles c (l:ls) = case splitnull l of
- ['a':mode, 'n':file, ""] ->
- parsefiles ((file, parsemode mode):c) ls
- (('p':_):_) -> (c, l:ls)
- _ -> parsefail
+ parsefiles c (l:ls) = parsefiles' c (splitnull l) l ls
+
+ parsefiles' c ['a':mode, 'n':file, ""] _ ls =
+ parsefiles ((file, parsemode mode):c) ls
+ parsefiles' c (('p':_):_) l ls = (c, l:ls)
+ -- Some buggy versions of lsof emit a f field
+ -- that was not requested, so ignore it.
+ parsefiles' c (('f':_):rest) l ls = parsefiles' c rest l ls
+ parsefiles' _ _ _ _ = parsefail
parsemode ('r':_) = OpenReadOnly
parsemode ('w':_) = OpenWriteOnly