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.

Title: pty.spawn() enhancements
Type: enhancement Stage: resolved
Components: Library (Lib) Versions: Python 3.2
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: BreamoreBoy, akuchling, fergushenderson, jamesh, nnorwitz, psss, r.david.murray
Priority: normal Keywords:

Created on 2004-06-05 16:29 by akuchling, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (9)
msg54176 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2004-06-05 16:29
(Originally suggested by James Henstridge in bug #897935)

There are also a few changes that would be nice to see
in pty.spawn:

1) get the exit status of the child. Could be fixed by
adding the following to the end of the function:
pid, status = os.waitpid(pid, 0)
return status

2) set master_fd to non-blocking mode, so that the
output is printed to the screen at the speed it is
produced by the child.
msg54177 - (view) Author: James Henstridge (jamesh) Date: 2004-06-09 14:16
Logged In: YES 

Since filing the original bug report, I got reports that
simply setting the fds to non-blocking caused problems under
Solaris.  Some details are available in this bug report:

The _copy() function never raised an IOError or OSError, so
it never exited.  I'd imagine that EOF could be detected by
getting back then empty string when reading from the fd when
select() says it is ready for reading, but I haven't checked
whether this works.
msg54178 - (view) Author: Neal Norwitz (nnorwitz) * (Python committer) Date: 2007-03-16 06:08
Wouldn't it be better to just return the pid.  The caller can get the status if they want or do anything else with the pid.  I'm guessing #2 is no longer requested?
msg54179 - (view) Author: James Henstridge (jamesh) Date: 2007-03-20 06:32
#2 was an old misunderstanding by me about vs. w.r.t pipes, so is not needed.

As for returning the status code vs the pid, it looks like spawn() is designed to return only when it can't read/write to the subprocess.  You could return the pid at this point, but the process has most likely finished running at this point so the only thing you'd be likely to do is call waitpid() on it (and it is necessary to call waitpid() for the child process to be cleaned up properly).

That's why I suggested that pty.spawn() get the child status itself.
msg66864 - (view) Author: Petr Splichal (psss) Date: 2008-05-15 15:02
Is there any plan to modify pty.spawn() so that it reports child's
status? I think this would be really a very useful feature.
msg88669 - (view) Author: Fergus Henderson (fergushenderson) Date: 2009-06-01 20:05
#1 is a duplicate of issue 2489 <>,
which has a patch attached.

According to the other discussion in this thread, #2 was a misunderstanding.

So I think we could close this bug as a duplicate.
msg115124 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-08-27 19:49
No, issue 2489 is a bug fix, and the inclusion of a feature request in it has already had an objection.  This bug should stay open to cover the feature request, I think.  The patch for the RFE is pretty simple...
msg190049 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-05-26 02:56
So #2489 broke at least one buildbot and this has to stay open for an enhancement request.  Frankly it all confuses the hell out of me, could someone please explain in words of one syllable or less, thanks.
msg190082 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2013-05-26 12:28
It looks like the problem on OpenIndiana with #2489 was fixed. As of May 25th, the 3.x build on OpenIndiana is a green.

So, 2) is a misunderstanding and 1) was carried out in #2489 (despite any objections to putting a feature enhancement in a bugfix, the feature is still there in trunk).  Therefore, I'm going to close this bug because there's nothing to do.
Date User Action Args
2022-04-11 14:56:04adminsetgithub: 40350
2013-05-26 12:28:39akuchlingsetstatus: open -> closed
resolution: out of date
messages: + msg190082

stage: test needed -> resolved
2013-05-26 02:56:14BreamoreBoysetnosy: + BreamoreBoy
messages: + msg190049
2010-08-27 19:49:33r.david.murraysetversions: + Python 3.2
nosy: + r.david.murray

messages: + msg115124

stage: test needed
2009-06-01 20:05:59fergushendersonsetnosy: + fergushenderson
messages: + msg88669
2008-05-15 15:02:18pssssetnosy: + psss
messages: + msg66864
2004-06-05 16:29:34akuchlingcreate