Skip to content

Clarify behaviour of close_fds on Windows #235

@robx

Description

@robx

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.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions