Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

createPipe doesn't work on Windows #181

Closed
TerrorJack opened this issue Jun 5, 2020 · 4 comments · Fixed by #182
Closed

createPipe doesn't work on Windows #181

TerrorJack opened this issue Jun 5, 2020 · 4 comments · Fixed by #182

Comments

@TerrorJack
Copy link
Contributor

TerrorJack commented Jun 5, 2020

Example program:

{-# LANGUAGE OverloadedStrings #-}

import qualified Data.ByteString as BS
import System.IO
import System.Process

main :: IO ()
main = do
  (h_read, h_write) <- createPipe
  let msg = "233"
  BS.hPut h_write msg
  hFlush h_write
  BS.hGet h_read (BS.length msg) >>= print

This prints "233" on Linux/macOS, but the program hangs indefinitely on Windows. Tested against ghc-8.10.1 which ships process-1.6.8.2, both on my Windows 10 laptop and on GitHub Actions.

@snoyberg
Copy link
Collaborator

snoyberg commented Jun 7, 2020

I don't have easy access to a Windows machine right now to test this out, and honestly don't have any ideas on what might be causing this. @Mistuke any thoughts?

Mistuke added a commit to Mistuke/process that referenced this issue Jun 7, 2020
Fixes haskell#181, the documentation seems to have been misread, the argument to `_pipe` is the number of bytes to reserve for pipe communications, not the number of pipes to create.  This ended up making pipes that can only send 2 bytes at a time.

Instead use 8k which is the size of the internal Buffers in `Base` which back `I/O` calls.
@Mistuke
Copy link
Contributor

Mistuke commented Jun 7, 2020

@snoyberg #182 fixes this. The code isn't broken it's just the buffer size is ridiculously low.

The write above blocks and is waiting for the read to drain it. but since everything is done on the same thread the program deadlocks.

@TerrorJack
Copy link
Contributor Author

@snoyberg I just validated locally and @Mistuke's patch works, with threaded/non-threaded runtime. Would be nice to have a minor release for the bugfix. Thanks for the timely patch :D

@snoyberg
Copy link
Collaborator

snoyberg commented Jun 8, 2020

Released on Hackage. Thanks @Mistuke!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants