os.fork and pty.fork

E

Eric Snow

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,733
Messages
2,569,439
Members
44,829
Latest member
PIXThurman

Latest Threads

Top