#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 guest): Malcolm, Could you elaborate on what you mean by "that's just the way Windows works"? I haven't looked at the file io implementation for GHC, but Windows is quite flexible here, in Windows msvcrt (stdio) is implemented in terms of CreateFile iirc, which has different sharing options. So it should be possible to match the behavior under Ubuntu. I did a quick test just in C on Vista (where the Haskell example reproduces the undesirable result under 6.10.2 also): {{{ #include <stdio.h> #include <stdlib.h> int main(void) { FILE* foo; FILE* bar; char buf[32]; foo = fopen("log.txt", "w"); if(!foo) { puts("error opening log.txt for writing"); return EXIT_FAILURE; } puts("Writing some text to log.txt\n"); fprintf(foo, "1,2,3,6,11,23,47,106,235\n"); fflush(foo); bar = fopen("log.txt", "r"); if(!bar) { puts("error opening log.txt for reading"); return EXIT_FAILURE; } if(!fgets(buf, 31, bar)) { puts("error reading from stream"); return EXIT_FAILURE; } else { printf("read: (%s) from file while it was open for writing.\n", buf); } fclose(foo); fclose(bar); return EXIT_SUCCESS; } }}} Which successfully reads the file that was open for writing: {{{ Output when compiled with gcc from mingw 3.4.5: Writing some text to log.txt read: (1,2,3,6,11,23,47,106,235 ) from file while it was open for writing. }}} -- Ticket URL: <http://hackage.haskell.org/trac/ghc/ticket/4363#comment:2> 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