I have a client/server daemon in PHP, which forks per request. Processes A and B can talk using inter process communication (IPC) with the method described in socket_create_pair. However, if the request being handled by B forks again (into process C) to handle a long running task after B exits, C can only communicate on the original IPC pair to A until B exits (because A drops the socket when SIGCHLD is handled, and A really has no idea C exists).
A -> listening process
B -> forked request process, will fork C
C -> forked request continuing a long task as B returns "In progress..." to the user.
(C can talk to A as long as B has not exited)
This is problematic because A manages some resources that can only be requested by IPC, and C naturally may end up causing an IPC request to A that blocks forever. Also, there is a risk of data corruption if B and C send any IPC at the same moment.
I've seen strategies for passing sockets between processes, but this doesn't seem to be possible in PHP's socket interface. I could use a non-paired socket listening on A that C can send requests to, but this is one way. Is there any other strategy in PHP to implement bidirectional IPC between A and C?