[Haskell-cafe] Exclusive mode in openFile

Gracjan Polak gracjanpolak at gmail.com
Thu Jun 30 00:11:30 CEST 2011

Gracjan Polak <gracjanpolak <at> gmail.com> writes:
> I'm looking for file locking code in GHC.IO.* modules, but cannot find any.

Just for the record: locking code resides in GHC.IO.FD in mkFD which calls

There is a heavy machinery underneath that is working hard to ensure Report's
semantics. Somebody must have spent a lot of effort in this place. Nice!

> How do I convince fdToHandle to create an independent handle to non-locked
> file?

Proper way to handle this is probably to add additional Bool parameter to mkFD,
fdToHandle and GHC.IO.FD.openFile that says if Report's semantics should be held
or not. Then openFileShared can be build on top of that.

(Possibly primed versions of these function will be needed to keep backward

If this could help anybody else out there beside me I could make this proposal
more concrete and follow library change procedure properly. If not I can live
with what I have hacked together till now.

Is there any interest in such a change?


More information about the Haskell-Cafe mailing list