__hscore_open from HsBase.h
Krasimir Angelov
kr.angelov at gmail.com
Tue Nov 14 09:34:49 EST 2006
On 11/14/06, Bulat Ziganshin <bulat.ziganshin at gmail.com> wrote:
> Hello Simon,
>
> Tuesday, November 14, 2006, 11:57:37 AM, you wrote:
>
> >> #ifdef mingw32_HOST_OS
> >> if ((how & O_WRONLY) || (how & O_RDWR) || (how & O_APPEND))
> >> return _sopen(file,how,_SH_DENYRW,mode);
> >> else
> >> return _sopen(file,how,_SH_DENYWR,mode);
> >> #else
> >> return open(file,how,mode);
> >> #endif
>
> > I haven't seen this code before, but I wonder if it's an attempt to implement
> > the single-writer multiple-reader locking semantics in the Haskell 98 IO library?
>
> so, the first question: WHO wrote this? may be SOF?
It was me.
> and second question: HOW this may help this semantics?? in my
> investigation, simple 'open' is just fine - it prevents writing by other
> processes to the file being written by Haskell program and it allow to
> read and write open by other processes of the file that i only read.
> may be it was problems on old windowses? and may be this some bug and
> this should be rewritten as DENY_WRITE and DENY_NONE, correspondingly
>
> btw, what is a semantics on Unix? is it the same as i mentioned above?
>
> i hope to fix this at least in Streams library so please help me
> understand what is a better plan
How do you propose to implement this without _sopen on Windows? By
default it is allowed to open any file for reading even if it is
already open for writing. Good example is System.Directory.copyFile.
On Unix copyFile "test" "test" fails while on Windows without locking
this silently truncates the requested file and returns.
Krasimir
More information about the Cvs-ghc
mailing list