[Haskell-cafe] fcntl locks, executeFile and threaded runtime
diego souza
dsouza at c0d3.xxx
Fri Oct 25 12:58:29 UTC 2013
Hi,
I'm having problems with executeFile as it seems to clear the advisory
locks using the threaded runtime. Consider the following snippet (a
simplification of what I'm doing):
import System.IO
import Control.Monad
import System.Posix.IO
import Control.Concurrent
import System.Posix.Files
import System.Posix.Process
main = do
let lock = (WriteLock, AbsoluteSeek, 0, 0)
fd <- openFd "/tmp/foobar" ReadWrite (Just stdFileMode) defaultFileFlags {trunc=True}
pid <- forkProcess $ do
setLock fd lock >> putStrLn "child: ok"
executeFile "/usr/bin/sleep" False ["5"] Nothing
threadDelay $ 1 * 1000 * 1000
setLock fd lock >> putStrLn "parent: fail!"
void $ getProcessStatus True False pid
Then I consistentlty get these results:
$ ghc -threaded --make test.hs; ./test
child: ok
parent: fail!
$ ghc -rtsopts --make test.hs; ./test
child: ok
test: setLock: resource exhausted (Resource temporarily unavailable)
Any pointers? At first I though it might be an issue with the unix
package but that doesn't seem to be the case.
$ ghc-pkg list | grep unix
unix-2.6.0.1
$ ./test +RTS --info
[("GHC RTS", "YES")
,("GHC version", "7.6.3")
,("RTS way", "rts_thr")
,("Build platform", "x86_64-unknown-linux")
,("Build architecture", "x86_64")
,("Build OS", "linux")
,("Build vendor", "unknown")
,("Host platform", "x86_64-unknown-linux")
,("Host architecture", "x86_64")
,("Host OS", "linux")
,("Host vendor", "unknown")
,("Target platform", "x86_64-unknown-linux")
,("Target architecture", "x86_64")
,("Target OS", "linux")
,("Target vendor", "unknown")
,("Word size", "64")
,("Compiler unregisterised", "NO")
,("Tables next to code", "YES")
]
Thanks!
~dsouza
More information about the Haskell-Cafe
mailing list