
#13497: GHC does not use select()/poll() correctly on non-Linux platforms -------------------------------------+------------------------------------- Reporter: nh2 | Owner: (none) Type: bug | Status: new Priority: normal | Milestone: Component: Runtime System | Version: 8.0.1 Resolution: | Keywords: Operating System: Unknown/Multiple | Architecture: | Unknown/Multiple Type of failure: None/Unknown | Test Case: Blocked By: | Blocking: 8684 Related Tickets: #8684, #12912 | Differential Rev(s): Wiki Page: | -------------------------------------+------------------------------------- Comment (by nh2): I have pushed a workaround to my branch [https://github.com/ghc/ghc/compare/ghc-8.2.1-release...nh2:ghc-8.2.1 -improve-fdRready-precision ghc-8.2.1-improve-fdRready-precision], namely commit [https://github.com/nh2/ghc/commit/1d037a16251751e98d4302f4be1e5659c3240958 1d037a16]. This completes my testing of my branch on Windows. I have tested the 4 of the 5 possible branches that `fdReady()` can take on Windows: 1. Testing the `FILE_TYPE_PIPE` case suceeded with `ghc-bug-13497 -accuracy-test.hs` (from [https://ghc.haskell.org/trac/ghc/ticket/13497#comment:18 comment 18]), by running it from the MSYS2 Mingw-w64 console (NOT `cmd.exe`!) 2. Testing the `FILE_TYPE_DISK` case succeeded with the following file `ghc-bug-13497-windows-file-test.hs`: {{{ import System.IO main = do writeFile "testfile" "hello" handle <- openFile "testfile" ReadMode hWaitForInput handle (5 * 1000) }}} 3. Testing the `FILE_TYPE_CHAR` case suceeded by running `ghc-bug-13497 -accuracy-test.hs` (see above) , but this time from `cmd.exe`. Here, focusing and unfocusing the Window triggers `EventType == FOCUS_EVENT` so that our loop is executed (I confirmed this with a print in the loop). 4. Testing the `if (isSock)` case succeded with the echo server example given in the previous comment. 5. I did not test the `default:` case ([https://github.com/nh2/ghc/blob/1d037a16251751e98d4302f4be1e5659c3240958/lib... this one]), because I don't know how to trigger it. There are 3 cases in which this branch could be taken according to the `GetFileType()` [https://msdn.microsoft.com/en- us/library/windows/desktop/aa364960(v=vs.85).aspx documentation]: A. `FILE_TYPE_REMOTE`, which seems impossible to create on modern Windows B. `FILE_TYPE_UNKNOWN`, for which it is literally unknown on how it can be created C. The very bottom of the `FILE_TYPE_PIPE` case, when `/* PeekNamedPipe didn't work - fall through to the general case */` happens. I don't know how to trigger this. Simon Marlow introduced this logic 9 years ago in commit [https://github.com/nh2/ghc/commit/1b0906e072344376ec7cb95afe314f2157b62b20 1b0906e0], so maybe he knows. In any case, with this testing done I'm reasonably confident that my branch doesn't regress Windows. -- Ticket URL: http://ghc.haskell.org/trac/ghc/ticket/13497#comment:25 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler