aboutsummaryrefslogtreecommitdiff
path: root/Utility/Lsof.hs
diff options
context:
space:
mode:
Diffstat (limited to 'Utility/Lsof.hs')
-rw-r--r--Utility/Lsof.hs7
1 files changed, 6 insertions, 1 deletions
diff --git a/Utility/Lsof.hs b/Utility/Lsof.hs
index 25581cc23..0061dfe57 100644
--- a/Utility/Lsof.hs
+++ b/Utility/Lsof.hs
@@ -26,11 +26,16 @@ data ProcessInfo = ProcessInfo ProcessID CmdLine
queryDir :: FilePath -> IO [(FilePath, LsofOpenMode, ProcessInfo)]
queryDir path = query ["+d", path]
+{- Runs lsof with some parameters.
+ -
+ - Ignores nonzero exit code; lsof returns that when no files are open.
+ -
+ - Note: If lsof is not available, this always returns [] !
+ -}
query :: [String] -> IO [(FilePath, LsofOpenMode, ProcessInfo)]
query opts = do
(pid, s) <- pipeFrom "lsof" ("-F0can" : opts)
let !r = parse s
- -- ignore nonzero exit code; lsof returns that when no files are open
void $ getProcessStatus True False $ processID pid
return r