[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.python

Re: os.pipe() + os.fork

Gary Herron

2/20/2010 7:14:00 PM

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

2 Answers

Sebastian Noack

2/23/2010 9:25:00 AM

0

On Feb 20, 8:13 pm, Gary Herron <gher...@islandtraining.com> wrote:
> Here's a thought:  Consider the subprocess module.   It can do thefork
> and any necessary pipes and can do so in an OS independent way.   It
> might make you life much easier.

As far as i know the subprocess module provides only functionality for
running any program as subprocess. But I just want to fork the current
process without putting some code in an external python script.

Sebastian Noack

aahz

2/25/2010 8:24:00 PM

0

In article <256926de-e175-4fa2-aa24-dbd5f96756ef@u20g2000yqu.googlegroups.com>,
sebastian.noack@googlemail.com <sebastian.noack@googlemail.com> wrote:
>On Feb 20, 8:13=A0pm, Gary Herron <gher...@islandtraining.com> wrote:
>>
>> Here's a thought: =A0Consider the subprocess module. =A0 It can do thefor=
>k
>> and any necessary pipes and can do so in an OS independent way. =A0 It
>> might make you life much easier.
>
>As far as i know the subprocess module provides only functionality for
>running any program as subprocess. But I just want to fork the current
>process without putting some code in an external python script.

Then try multiprocessing
--
Aahz (aahz@pythoncraft.com) <*> http://www.python...

"Many customs in this life persist because they ease friction and promote
productivity as a result of universal agreement, and whether they are
precisely the optimal choices is much less important." --Henry Spencer