Question

I am trying to execute a program from a parent using execl. I do the normal pipe setup and fork. Here is the trick... I need my children (there can be an arbitrary number of children) to all communicate with the parent.

Program "A" (parent) creates pipe forks and execl into "B" (child). In the main() function of program B I need to be able to read and write to the pipe.

Is there any way to access my pipe file descriptors in the child process after the excel takes over and executes my child process?

Thank you, ~Eric

Was it helpful?

Solution

execl(3) has no effect on file descriptors, with one exception

It is possible to mark a file descriptor close-on-exec with fcntl(2), but generally the various flavors of execve(2) have no effect on open file descriptors and they remain open in children.

OTHER TIPS

Read Beej's Guide to Unix Interprocess Communication ( you can find it at http://beej.us/guide/ ), particularly section 4.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top