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. 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. Evan Driscoll
    Replies:
    0
    Views:
    230
    Evan Driscoll
    Oct 24, 2012
  2. Evan Driscoll
    Replies:
    0
    Views:
    183
    Evan Driscoll
    Oct 24, 2012
  3. Evan Driscoll
    Replies:
    0
    Views:
    210
    Evan Driscoll
    Oct 24, 2012
  4. David Hutto
    Replies:
    0
    Views:
    221
    David Hutto
    Oct 24, 2012
  5. David Hutto
    Replies:
    0
    Views:
    205
    David Hutto
    Oct 24, 2012
Loading...

Share This Page