I think that when you do fork () in C, you cannot pass any handle from the child process back to the parent, but maybe I'm wrong. Only what you get is the PID of the new child process. The best way is to open a channel (with a conditional name, for example, the channel name contains the PID of the process), and then you can open it from anywhere.
Finally, when you execute the fork () process, it gives you the PID, and you can write both the PID (C binary and forked) in the stdout of the C program, for example with a separator:
cpid = fork(); printf("%d|%d", (int)get_pid(), cpid);
Good luck :)
source share