aboutsummaryrefslogtreecommitdiff
path: root/Utility/Lsof.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2014-11-12 18:00:40 -0400
committerGravatar Joey Hess <joey@kitenet.net>2014-11-12 18:00:40 -0400
commit6f15850b2cd33486c091a6dcb7a8357ed8ff79ea (patch)
tree82f50254bc496391257785746806bf40d20c2e6f /Utility/Lsof.hs
parent003df7d397471cac6508a5ef0348547356946436 (diff)
Work around apparent bug in lsof 4.88's -F output format.
Diffstat (limited to 'Utility/Lsof.hs')
-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