I have multiple subprocesses starting from a parent process and to aid with debugging they are set up as separate executables and I want to communicate with them via a passed socket.
I’m currently using named sockets to do this, but that requires interfacing with the file system, and it seems like just passing the file descriptor would be a more correct way to do this. The other alternative would be to use a port and the loopback address, but that seems a touch hacky.
From what I can tell if the processes were just simply forked this becomes easy since the file descriptors are still in the same memory and thus everything is fine, however since these are started from executables they don’t share the same memory. Thus I need some way to turn the arguments of the executable into a file descriptor.
The issue is that I can’t find a function that would take a
int and return the corresponding file descriptor (apart from the
openfile function which takes a file path).
Additionally I’m not sure if this is the right way to do this since if the subprocess was called by another langague/cli the string formatting would potentially not be identical thus I’d need to use a hex representation/otherwise to ensure that they are talking about the same file descriptor.