Issue590513
This issue tracker has been migrated to GitHub,
and is currently read-only.
For more information,
see the GitHub FAQs in the Python's Developer Guide.
Created on 2002-08-03 14:16 by rasjidw, last changed 2022-04-10 16:05 by admin. This issue is now closed.
Files | ||||
---|---|---|---|---|
File name | Uploaded | Description | Edit | |
pty-extended-patch | rasjidw, 2002-08-03 14:16 | Patch to implement popen2 in pty.py | ||
pty-extended-patch3 | rasjidw, 2002-08-16 12:39 | Updated patch to implement popen2 in pty.py | ||
pty-extended-patch4 | rasjidw, 2002-08-30 03:54 | New patch also returns pid of child process. |
Messages (14) | |||
---|---|---|---|
msg40801 - (view) | Author: Rasjid Wilcox (rasjidw) | Date: 2002-08-03 14:16 | |
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. |
|||
msg40802 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-08-04 08:56 | |
Logged In: YES user_id=21627 Can you please write documentation and a test case? |
|||
msg40803 - (view) | Author: Rasjid Wilcox (rasjidw) | Date: 2002-08-05 11:34 | |
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. |
|||
msg40804 - (view) | Author: Martin v. Löwis (loewis) * | Date: 2002-08-05 11:44 | |
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. |
|||
msg40805 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2002-08-05 15:20 | |
Logged In: YES user_id=6380 I mostly concur with Martin von Loewis's comments, though I'm not sure this is big enough for a PEP. I think that you're right in answering (yes, no, yes) but I have no information (portability of this module is already limited to IRIX and Linux, according to the docs). The docs use the word "baffle" -- I wonder if you could substitute something else or generally clarify that sentence; it's not very clear from the docs what spawn() does (nor what fork() does, to tell the truth -- all these could really use some examples). |
|||
msg40806 - (view) | Author: Rasjid Wilcox (rasjidw) | Date: 2002-08-16 12:39 | |
Logged In: YES user_id=39640 Okay. This is essentially my final version, subject to an issue around the naming of a couple of the modules functions. My issue is that the pty.spawn funciton does not return. My new one 'th_spawn' function does. I believe quite strongly that to be consistent with the rest of python, 'th_spawn' should be renamed 'spawn', and the current spawn function should be renamed something like '_master' since it takes the place of the pty master. The issue of course is backward compatibility. However, I believe this to be relatively minor for two reasons. 1. I think very few (if any) people are using it, since it was a) largely undocumented, b) didn't always work c) wasn't particularly useful, since it only allowed control from an existing pty (so what was the point?) 2. If anyone is using it, they would _almost_ certainly be starting it on a new thread, so all that would happen if the functions were renamed would be that an extra (redundant) sub-thread is created. I have posted to comp.lang.python to see what other pty.py users think. Subject to the response here and there, I may post to python-dev in due course. Rasjid. |
|||
msg40807 - (view) | Author: Thomas Wouters (twouters) * | Date: 2002-08-16 13:47 | |
Logged In: YES user_id=34209 The pty module actually works on all platforms that provide openpty(). I know at least BSDI and FreeBSD do, in addition to Linux, and I suspect OpenBSD and NetBSD as well, and possibly other BSD-derived systems. Still, it is very unlikely to work on non-POSIX-ish systems, so /bin/sh is a safe bet. I can take a look at the patch, and test it on a variety of machines, but not before I leave on a two-week vacation, this sunday :) I have plenty of time to look at it when I'm back though, in the first week of September. Feel free to assign the patch to me, as a reminder. |
|||
msg40808 - (view) | Author: Guido van Rossum (gvanrossum) * | Date: 2002-08-20 18:33 | |
Logged In: YES user_id=6380 Assigning this to Thomas Wouters according to his wishes. |
|||
msg40809 - (view) | Author: Rasjid Wilcox (rasjidw) | Date: 2002-08-30 03:54 | |
Logged In: YES user_id=39640 Okay. My final version (I promise!). The code has been reorganised a little so that: a) it is cleaner to read b) the popen2 function now returns the pid of the child process Rasjid. |
|||
msg40810 - (view) | Author: Thomas Wouters (twouters) * | Date: 2002-09-09 13:57 | |
Logged In: YES user_id=34209 I have several comments, but I'm not sure if they've been adressed in other forums or not. Guido mentions documentation, but the patches attached don't seem to contain them; are they seperate ? I also don't see a testcase. - Why threads ? A seperate non-thread version, with a third process to handle the data trafficking, and falling back to that when threads are not available would be nice. - I concur the new behaviour is much more useful. However, I'm a stickler for backward compatibility, so I advice against renaming the old spawn :) - I don't like 'th_spawn'. 'spawn_thread' or 'threaded_spawn' or some such sound better to me (but see above about threads.) - Some minor whitespace issues (the line-wrap on line 150 is not necessary, line 179 is too long, and the backslashes on lines 190 and 205 are not necessary.) A comment describing why the tty.setraw() is done would also be nice. |
|||
msg40811 - (view) | Author: Rasjid Wilcox (rasjidw) | Date: 2002-09-10 11:38 | |
Logged In: YES user_id=39640 Thanks for the comments Thomas. a) I have not done docs or testcase yet. I wanted to be clear about the direction first. I will submit with my next version. b) No particular reason for threads, just more intuitive to me. On due reflection, os.fork is better. I shall drop the use of threads. c) I shall keep backward compatibility. Perhaps 'returning_spawn' for the new version. With luck, next version in a couple of weeks. |
|||
msg40812 - (view) | Author: Neal Norwitz (nnorwitz) * | Date: 2003-01-01 20:09 | |
Logged In: YES user_id=33168 What is the status of this patch? Rasjid do still plan to produce an updated patch. Note: 2.3 alpha 1 was released yesterday. |
|||
msg40813 - (view) | Author: Rasjid Wilcox (rasjidw) | Date: 2003-01-02 10:22 | |
Logged In: YES user_id=39640 I do plan to do so, but some of Thomas' comments required some thought, and in the meantime other priorities came up. Also, writing docs and a testcase will take some time (and thought) and seem to be the most requrested aspect. Realistically, I would expect to get to it within the next month or two. Unfortunately, I can't really promise much more than that. |
|||
msg40814 - (view) | Author: Neal Norwitz (nnorwitz) * | Date: 2003-04-12 01:27 | |
Logged In: YES user_id=33168 I am rejecting this patch due to no activity. Rasjid, if you are still interested in completing the patch, with test, and documentation, feel free to re-open this report or add a new one. Thanks. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-10 16:05:33 | admin | set | github: 36975 |
2002-08-03 14:16:26 | rasjidw | create |