add lsof build deps
Check for it in configure; and add a --force option for people without it who want to live dangerously.
This commit is contained in:
parent
5d63c2a4bb
commit
0052cec2b7
5 changed files with 32 additions and 3 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue