#4363: openFile sharing permissions are inconsistent across platforms ---------------------------------+------------------------------------------ Reporter: jystic | Owner: Type: bug | Status: new Priority: normal | Component: libraries/base Version: 6.12.3 | Keywords: Testcase: | Blockedby: Os: Windows | Blocking: Architecture: Unknown/Multiple | Failure: Incorrect result at runtime ---------------------------------+------------------------------------------
Comment(by jystic): I'm not 100% sure, but it looks like openFile ends up calling !__hscore_open from libraries\base\include\HsBase.h: {{{ #ifdef __MINGW32__ INLINE int __hscore_open(wchar_t *file, int how, mode_t mode) { if ((how & O_WRONLY) || (how & O_RDWR) || (how & O_APPEND)) return _wsopen(file,how | _O_NOINHERIT,_SH_DENYRW,mode); // _O_NOINHERIT: see #2650 else return _wsopen(file,how | _O_NOINHERIT,_SH_DENYWR,mode); // _O_NOINHERIT: see #2650 } #else INLINE int __hscore_open(char *file, int how, mode_t mode) { return open(file,how,mode); } #endif }}} The documentation for [http://msdn.microsoft.com/en- us/library/w7sa2b22(VS.80).aspx _wsopen] suggests that there are four options that can be passed to it to change the sharing behaviour: '''_SH_DENYRW''' Denies read and write access to a file. '''_SH_DENYWR''' Denies write access to a file. '''_SH_DENYRD''' Denies read access to a file. '''_SH_DENYNO''' Permits read and write access. We pass _SH_DENYRW (deny reads, deny writes) in the case that we are writing to the file and _SH_DENYWR (deny writes, allow reads) in the case that we are reading from the file but not writing to it. If we were to always use _SH_DENYWR then I think it would give the desired behaviour. -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4363#comment:3> GHC <http://www.haskell.org/ghc/> The Glasgow Haskell Compiler _______________________________________________ Glasgow-haskell-bugs mailing list Glasgow-haskell-bugs@haskell.org http://www.haskell.org/mailman/listinfo/glasgow-haskell-bugs