haskell / haskell/process

Clarify behaviour of `close_fds` on Windows

Open
#235 3 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 documentation of `close_fds` states that:

> Close all file descriptors except stdin, stdout and stderr in the new process (on Windows, only works if std_in, std_out, and std_err are all Inherit).

It's quite unclear what "only works" means. Will things blow up if I set `close_fds` and `CreatePipe`? My best guess is something like "if any of `std_in`, `std_out`, `std_err` are not `Inherit`, those will be closed too".

Specifically, based on the documentation, I can't answer the question whether

```
(rstdin, wstdin) <- createPipe
(_,_,_,p) <- createProcess (proc "cat" []) { std_in = UseHandle rstdin, close_fds = True }
hPutStr wstdin "foo"
hClose wstdin
waitProcess p
```

should work on Windows. (This hangs on Linux without `close_fds`, (apparently) because the child inherits the open write-end, causing the pipe to stay open despite `hClose`.)

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.