Haskell for non-Haskell's sake

Simon Marlow simonmar@microsoft.com
Fri, 5 Sep 2003 14:39:52 +0100


=20
> I implemented a trivial "database", stored in ordinary files,=20
> and had to
> ensure mutual exclusion of database access between=20
> simultaneously running
> CGI scripts. Since each CGI run is short, I simply locked the entire
> database for the entire run. Claiming a lock on a file is=20
> easy in C (well,
> it takes 18 lines...), but there's nothing in the standard Haskell
> libraries that can do it. So I borrowed a little C code from=20
> the net, and
> called it via the FFI.

Locking support is available in the unix package distributed with GHC.
See:

http://www.haskell.org/ghc/docs/latest/html/unix/System.Posix.IO.html#7


Cheers,
	Simon