[Haskell-cafe] File locked unnecessarily (the continuation)
ariep at xs4all.nl
Fri Jan 19 21:23:13 EST 2007
Some time ago I reported a strange file locking problem. I have reduced my
offending program to a relatively small size.
This reduction process was quite entertaining. At one point, I could
reliably turn the locking off and on by removing and reintroducing a
certain unused import :s. I was happy to see this go away on cutting out
The example is attached. Open the tarball and run "ghc --make Main -O &&
./a.out" in the resulting directory.
On my system (amd64 Gentoo linux, ghc 6.4.2), this gives the following
Chasing modules from: Main
Compiling Interface ( ./Interface.hs, ./Interface.o )
Compiling Main ( Main.hs, Main.o )
Compiling plugin P
a.out: a.txt: openFile: resource busy (file is locked)
There is no reason for the file "a.txt" to be locked.
The problem is somewhat brittle: any one of the following changes makes it
- in "Main.hs:main", replacing the 'c' argument of 'cat' (the one
dynamically loaded from the plugin 'P') by 'Interface.c';
- in "Main.hs:main", removing one of the two 'cat c' calls;
- in "Interface.hs:c", removing one of the two 'a' calls.
Because of the first of these, it seems that the problem is partly caused
by the dynamic linking, but I'm not sure about that (the "unused import"
experience made me a bit paranoid ;-) ).
Can someone comment on the cause of this locking issue, or maybe further
simplify the example?
Thanks and greetings,
More information about the Haskell-Cafe