简体   繁体   中英

execl pipe without dup

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 BI 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

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM