[Patches] [ python-Patches-590513 ] Add popen2 like functionality to pty.py.

noreply@sourceforge.net noreply@sourceforge.net
Mon, 05 Aug 2002 04:44:06 -0700


Patches item #590513, was opened at 2002-08-03 16:16
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=590513&group_id=5470

Category: Library (Lib)
Group: Python 2.2.x
Status: Open
Resolution: None
Priority: 5
Submitted By: Rasjid Wilcox (rasjidw)
Assigned to: Nobody/Anonymous (nobody)
Summary: Add popen2 like functionality to pty.py.

Initial Comment:
This patch adds a popen2 like function to pty.py.

Due to use of os.execlp in pty.spawn, it is not quite
the same, as all the arguments (including the command
to be run) must be passed as a tupple.

It is only a first draft, and may need some more work,
which I am willing to do if some direction is indicated.

Tested on Python2.2, under RedHat Linux 7.3.

Rasjid.


----------------------------------------------------------------------

>Comment By: Martin v. Löwis (loewis)
Date: 2002-08-05 13:44

Message:
Logged In: YES 
user_id=21627

I'm not a regular pty user. Please ask those questions in
comp.lang.python, and python-dev. You can also ask previous
authors to pty for comments.

Uncertainty in such areas might be a hint that a library PEP
is need, to justify the rationale for all the details.

There is no need to hurry - Python 2.3 is still months away.

That said, I do think that this functionality is desirable,
so I'd encourage you to complete this task.

----------------------------------------------------------------------

Comment By: Rasjid Wilcox (rasjidw)
Date: 2002-08-05 13:34

Message:
Logged In: YES 
user_id=39640

Before I do docs etc, I have a few questions:

1.  I could make it more popen2 like by changing the args to
def popen2(cmd, ....)  and adding argv=('/bin/sh','-c',cmd)

Is this a better idea?  Does it reduce portability?  Is it
safe to assume that all posix systems have /bin/sh? (My
guess is yes, no and yes.)

2.  Should the threading done in the pty.popen2 function be
moved to a separate function, to allow more direct access to
spawn.  (The current spawn function does not return until
the child exits or the parent closes the pipe).

3.  Should I worry about how keyboard interrupts are
handled?  In some cases an uncontrolled process may be left
hanging around.  Or is it the job of the calling process to
deal with that?

Lastly, I am away for a week from Wednesday, so I won't be
able to do much until I get back, but I will try and finish
this off then.

Cheers,

Rasjid.


----------------------------------------------------------------------

Comment By: Martin v. Löwis (loewis)
Date: 2002-08-04 10:56

Message:
Logged In: YES 
user_id=21627

Can you please write documentation and a test case?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=305470&aid=590513&group_id=5470