I have the following situation (pseudocode):
function f:
pid = fork()
if pid == 0:
exec to another long-running executable (no communication needed to that process)
else:
return "something"
f
is exposed over a XmlRpc++ server. When the function is called over XML-RPC, the parent process prints "done closing socket" after the function returned "something". But the XML-RPC client hangs as long as the child process is still running. When I kill the child process, the XML-RPC client correctly finishes the RPC call.
It seems to me that I'm having a problem with fork()
copying socket descriptors to the child process (parent called closesocket
but child still owns a reference -> connection still established). How can I circumvent this?
EDIT: I read about FD_CLOEXEC
already, but can't I force all descriptors to be closed on exec
?