I'm currently working on a little tool that redirects cmd.exe I/O to a server by using pipes.
Everything worked like a charm, but I noticed a bug.
When I create the process using CreateProcess(), I set bInheritHandles to TRUE, in order to inherit the pipe handles.
But when the program gets terminated forcefully, the child process (cmd.exe) stays alive. At first, I thought it's not that big of a deal. But when the child process stays alive, somehow, my SOCKET handle doesn't get closed and the server will not notice the disconnect, though the parent process exited.
Is my assumption right?
And if it is, how would I close the child process when the parent process terminates?
Thank y'all in advance! 🤝
Everything worked like a charm, but I noticed a bug.
When I create the process using CreateProcess(), I set bInheritHandles to TRUE, in order to inherit the pipe handles.
But when the program gets terminated forcefully, the child process (cmd.exe) stays alive. At first, I thought it's not that big of a deal. But when the child process stays alive, somehow, my SOCKET handle doesn't get closed and the server will not notice the disconnect, though the parent process exited.
Is my assumption right?
And if it is, how would I close the child process when the parent process terminates?
Thank y'all in advance! 🤝

