[Haskell-cafe] fcntl locks, executeFile and threaded runtime
diego souza
dsouza at c0d3.xxx
Mon Oct 28 17:16:48 UTC 2013
Sorry, I've sent the wrong snippet. This is the correct one:
main = do
let lock = (WriteLock, AbsoluteSeek, 0, 0)
fd <- openFd "/tmp/foobar" ReadWrite (Just stdFileMode) defaultFileFlags {trunc=True}
pid1 <- forkProcess $ do
setLock fd lock >> putStrLn "child: locked!"
executeFile "/usr/bin/sleep" False ["5"] Nothing
pid2 <- forkProcess $ do
setLock fd lock >> putStrLn "parent: locked!"
executeFile "/usr/bin/sleep" False ["5"] Nothing
threadDelay $ 1 * 1000 * 1000
mapM_ (getProcessStatus True False) [pid1, pid2]
~dsouza
More information about the Haskell-Cafe
mailing list