
Andrew Coppin wrote:
Don Stewart wrote:
Hey Andrew,
What are you trying to do? Read and write to the same file (if so, you need to use strict IO), or are you trying something sneakier?
I have a long-running Haskell program that writes status information to a log file. I'd like to be able to open and read that log file before the program has actually terminated. I have a similar program written in Tcl that allows me to do this, since apparently the Tcl interpretter doesn't lock output files for exclusive access. Haskell, however, does. (This seems to be the stipulated behaviour as per the Report.) If there's an easy way to change this, it would be useful...
AIUI, and I could be wrong: The haskell report mandates locking. On win32, this locking is implemented using win32 (mandatory) locking primitives, and thus it affects other processes. On unix, this locking is implementing using an advisory/optional locking system which is only noticed by other haskell threads. (On many versions of unix, at least historically, there was no mandatory locking; mandatory locking is an anathema to unix programmers) Thus, the problem you have is win32 specific and requires access to the Win32 primitive to resolve, as I understand it. There are probably primitives in Win32 packages for this? Or you could use appendfile instead, Jules