aboutsummaryrefslogtreecommitdiff
path: root/Utility/Lsof.hs
diff options
context:
space:
mode:
authorGravatar Joey Hess <joey@kitenet.net>2012-06-15 23:24:01 -0400
committerGravatar Joey Hess <joey@kitenet.net>2012-06-15 23:29:39 -0400
commit0052cec2b7e39652bd52cd4978ed47d2daa5af68 (patch)
tree2c9b2262988886e95f3c45716913dc51502605a3 /Utility/Lsof.hs
parent5d63c2a4bbf910c859e873f6e27aef3453992b43 (diff)
add lsof build deps
Check for it in configure; and add a --force option for people without it who want to live dangerously.
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