Issue with child process on windows

  createprocess, windows

I am experiencing a very weird issue on Windows, i need pointers on what the root cause could be to further debug it.

Language is C/C++, involved API is CreateProcess.

I have a "parent" process that start a "child" process. Child process, on which i have no control, will use a pthread to connect with TCP sockets to the parent. The child also links some external proprietary libraries which seems to the be trigger for the issue.

At a given time, the socket is closed and the thread is terminated gracefully. The child process does not end at this point, but loops back and can connect again on request.

Both processes are command-line processes, they don’t create windows at all, just the normal black console window.

I develop the "parent" process, so i am looking at what i am doing wrong there!

Well, if the child is started manually from a dedicated cmd, eveyrthing works just fine.

If the child process is started from the parent instead, something breaks.
The sockets are closed on the child side, while the parent side does not sees the closed sockets. This causes the child to attempt reconnect and be refused (the parent think the child is STILL connected and refuses, due to internal logic).

What baffles me is that if run child directly from console, all works just fine. But if child is run by CreateProcess inside parent, all hell breaks loose.

What should i check on the parent to address this issue?

Source: Windows Questions