HaxeFoundation / HaxeFoundation/hxcpp

Reading from stdout of a process can hang on windows

Open
#975 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
330
Forks
227
Avg merge
2d 16h
Merged PRs (30d)
18

Description

Noticed that sometimes reading from the stdout of a process never returns on windows. Digging into things it seems like when the child process closes the stdout pipe isn't closed as it inherits from the parent process, so `ReadFile` will block forever as the child process has closed and there will never be more data in stdout.

I managed to work around this by setting `HANDLE_FLAG_INHERIT` to 0 using `SetHandleInformation` on the stdout pipe (https://stackoverflow.com/questions/54416116/readfile-does-not-return-while-reading-stdout-from-a-child-process-after-it-ends), but if I also apply that to the stderr pipe then reading from stdout will start to block again so I'm not sure what a proper fix would be.

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.