DaanDeMeyer / reproc

A cross-platform (C99/C++11) process library
MIT License
552 stars 65 forks source link

[Windows] reproc doesn't wait for process to fully start #73

Open HellsingDarge opened 2 years ago

HellsingDarge commented 2 years ago

CreateProcess returns when the process begun starting rather than it has fully started and it's waiting for inputs/processing, which can lead to errors (e.g. 0xC0000142) when the object holding the process instance or the executable context itself exits before it's fully started

DaanDeMeyer commented 2 years ago

I don't have access to a WIndows machine anymore so it'd be great if you could open a PR that has reproc wait for the process to finish initializing using WaitForInputIdle.

HellsingDarge commented 2 years ago

Which is used to wait for a window's object to be fully initialised (it's opened and displaying) and waiting for input (keypress, mouse, minimise, resize etc). And as I've searched through Microsoft docs, there doesn't seem to be a function that waits until all DLLs are loaded for a process, so the only option left is to arbitrarily wait after creation and hope that no out/err is lost before the drain is set up.