haskell / haskell/process

Deadlock on Windows Server 2012 when passing same pipe for stdout and stderr

Open
#76 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
Haskell
Stars
91
Forks
91
PR merge metrics
No merged PRs in 30d

Description

The following Haskell program, built with GHC 8.0.1, deadlocks on Windows Server 2012:

```
import System.Process
import System.IO
import System.Exit
main = do
hSetBuffering stderr NoBuffering
hSetBuffering stdout NoBuffering
(readIn, writeIn) <- createPipe
(readOut, writeOut) <- createPipe
(_,_,_,proch) <- createProcess (proc "python" ["-i"]) {
std_in = UseHandle readIn,
std_out = UseHandle writeOut,
std_err = UseHandle writeOut
}
hPutStrLn writeIn "print(42)"
hPutStrLn writeIn "quit()"
hClose writeIn
exit <- waitForProcess proch
hPutStrLn stderr =<< hGetContents readOut
hClose readOut
exitWith exit
```

You can reproduce the error on AppVeyor with the following repository: https://github.com/ezyang/ghceye (appveyor.yml included).

It does not appear to deadlock on Windows 10 or Linux. I have not attempted to reproduce on a local install of Windows Server 2012. I tried this similar Python code which did not deadlock, which is why I believe it to be a bug in the process library:

```
import subprocess
import os

(rin, win) = os.pipe()
(rout, wout) = os.pipe()
p = subprocess.Popen(["python", "-i"], stdin=rin, stdout=wout, stderr=wout)
os.write(win, "print(2)")
os.write(win, os.linesep)
os.write(win, "quit()")
os.write(win, os.linesep)
p.wait()
```

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.