Handmade Hero»Forums»Code
Mārtiņš Možeiko
2562 posts / 2 projects
Day 192: executing system command
On Windows you need to call CloseHandle not only on process handle hProcess, but also on thread handle hThread.

It's in the docs - https://msdn.microsoft.com/en-us/...ary/windows/desktop/ms684873.aspx
If the function succeeds, be sure to call the CloseHandle function to close the hProcess and hThread handles when you are finished with them. Otherwise, when the child process exits, the system cannot clean up the process structures for the child process because the parent process still has open handles to the child process.

You can close this handle immediately after CreateProcess returns, no need to wait until process terminates.
Casey Muratori
801 posts / 1 project
Casey Muratori is a programmer at Molly Rocket on the game 1935 and is the host of the educational programming series Handmade Hero.
Day 192: executing system command
Thanks Martins... I'll try to remember on tomorrow's stream.

- Casey
Kim
Kim Jørgensen
64 posts
Day 192: executing system command
Could we make the arguments to DEBUGExecuteSystemCommand less platform dependant? Wouldn't it be sufficient to just pass an enum with a command, like "build"?

I did manage to implement support for this on Linux (and presumably OS X) but it is not particularly pretty.

/Kim