os.pipe() + os.fork()
Gary Herron
gherron at islandtraining.com
Sat Feb 20 14:13:45 EST 2010
Sebastian Noack wrote:
> I have figured out that, you have to close the writing end in the child
> process, which is reading from the pipe. Otherwise the underlying pipe
> is not going to be closed when the parent process is closing its
> writing end. This has nothing to do with Python itself. I have tried
> plain C and there it is the same behaviour.
>
> Regards
> Sebastian Noack
>
Correct. The fork creates two processes with references to the read and
write ends of the pipe. Both parent and child processes should close
the ends they are not using.
Here's a thought: Consider the subprocess module. It can do the fork
and any necessary pipes and can do so in an OS independent way. It
might make you life much easier.
Gary Herron
More information about the Python-list
mailing list