I have a small application that redirects the stdout/in of an another app (usually command prompt or bash for windows). The problem is that if the connection is interrupted the my process has no idea and it never closes because of this line:
WaitForSingleObject(childProcess.hThread, INFINITE)
I was thinking of having a loop with something like this:
while(true)
{
if(ProcessIsDead(childProcess.hThread))
// close socket and exit
if(SocketIsDisocnnected(hSocket))
// close process and exit
}
What functions would I use to accomplish this? For ProcessIsDead I know there is a winapi for getting the exit code but I don't know how to check if the socket is disconnected without calling recv (which i cant do)