os.fork and pty.fork

Discussion in 'Python' started by Eric Snow, Jan 8, 2009.

  1. Eric Snow

    Eric Snow Guest

    I am trying to wrap my head around an issue here that has to do with
    running python without a tty. I use pexpect to connect to ssh and run
    some commands. However, if my script runs from a process which I
    forked using os.fork my pexpect spawn object can't open a good file
    descriptor in which to run my ssh command, as far as I can tell.
    pexpect uses pty.fork to fork the process, attach a tty, and run my
    command in the child with os.exec.

    When I go to expect something on the spawn object the read on the fd
    of the child returns EOF, which indicates that the child's fd is
    already closed before I did anything. This is the point at which I am
    trying to make sense of things. pty.fork gave pexpect the child's fd
    but does that fd actually go to a tty? Does the fact that my use of
    pexpect happens in a process which is not running in a tty, as it was
    generated from os.fork? It looks like pty.fork tries to use
    os.forkpty but I am not sure how an existing tty plays in to getting a
    new tty for the child process...

    Any insight into os.fork and pty.fork would be great. Thanks.

    -eric
     
    Eric Snow, Jan 8, 2009
    #1
    1. Advertisements

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. Justin Dubs

    pty difficulties

    Justin Dubs, Jan 24, 2004, in forum: Python
    Replies:
    3
    Views:
    505
    Josiah Carlson
    Jan 24, 2004
  2. Dave Platten

    pty.py

    Dave Platten, May 5, 2004, in forum: Python
    Replies:
    0
    Views:
    549
    Dave Platten
    May 5, 2004
  3. morphex
    Replies:
    2
    Views:
    424
    morphex
    Jan 6, 2005
  4. Adriaan Renting

    pty code from 2.3.4 not working in 2.3.5

    Adriaan Renting, Jun 16, 2005, in forum: Python
    Replies:
    0
    Views:
    328
    Adriaan Renting
    Jun 16, 2005
  5. Dan Stromberg

    Logging all activity on a tty/pty?

    Dan Stromberg, Aug 24, 2005, in forum: Python
    Replies:
    2
    Views:
    578
    Benji York
    Aug 24, 2005
  6. Replies:
    0
    Views:
    1,608
  7. Bret Jolly
    Replies:
    2
    Views:
    669
    Bret Jolly
    May 18, 2004
  8. Evan Driscoll
    Replies:
    0
    Views:
    290
    Evan Driscoll
    Oct 24, 2012
Loading...