Re: os.pipe() + os.fork()

Discussion in 'Python' started by Gary Herron, Feb 20, 2010.

  1. Gary Herron

    Gary Herron Guest

    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
    Gary Herron, Feb 20, 2010
    #1
    1. Advertising

  2. Gary Herron

    Guest

    On Feb 20, 8:13 pm, Gary Herron <> 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
    , Feb 23, 2010
    #2
    1. Advertising

  3. Gary Herron

    Aahz Guest

    In article <>,
    <> wrote:
    >On Feb 20, 8:13=A0pm, Gary Herron <> 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 () <*> http://www.pythoncraft.com/

    "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
    Aahz, Feb 25, 2010
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hoegje
    Replies:
    2
    Views:
    22,541
    Gianni Mariani
    Dec 5, 2003
  2. PC

    pipe() dup2() fork() execl() select()

    PC, Aug 9, 2003, in forum: C Programming
    Replies:
    3
    Views:
    1,254
  3. Rafael Giannetti Viotti

    Subprocess and pipe-fork-exec primitive

    Rafael Giannetti Viotti, Jul 30, 2007, in forum: Python
    Replies:
    2
    Views:
    3,008
    Rafael V.
    Aug 1, 2007
  4. Eric Snow

    os.fork and pty.fork

    Eric Snow, Jan 8, 2009, in forum: Python
    Replies:
    0
    Views:
    571
    Eric Snow
    Jan 8, 2009
  5. Sebastian Noack

    os.pipe() + os.fork()

    Sebastian Noack, Feb 20, 2010, in forum: Python
    Replies:
    0
    Views:
    333
    Sebastian Noack
    Feb 20, 2010
Loading...

Share This Page