| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
A parent and child can communicate through any of the normal inter-process communication schemes (pipes, sockets, message queues, shared memory), but also have some special ways to communicate that take advantage of their relationship as a parent and child.
One of the most obvious is that the parent can get the exit status of the child.
Since the child inherits file descriptors from its parent, the parent
can open both ends of a pipe, fork, then the parent close one end and
the child close the other end of the pipe. This is what happens when
you call the popen() routine to run another program from within
yours, i.e. you can write to the file descriptor returned from
popen() and the child process sees it as its stdin, or you can
read from the file descriptor and see what the program wrote to its
stdout. (The mode parameter to popen() defines which; if you want
to do both, then you can do the plumbing yourself without too much
difficulty.)
Also, the child process inherits memory segments mmapped anonymously (or by mmapping the special file ‘/dev/zero’) by the parent; these shared memory segments are not accessible from unrelated processes.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] |
This document was generated on September, 10 2007 using texi2html 1.77.