homepage

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.

classification
Title: pty.spawn handles errors improperly
Type: behavior Stage: needs patch
Components: Library (Lib) Versions: Python 3.4, Python 3.5, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: martin.panter, niemeyer
Priority: normal Keywords:

Created on 2013年04月24日 02:59 by niemeyer, last changed 2022年04月11日 14:57 by admin.

Messages (4)
msg187681 - (view) Author: Gustavo Niemeyer (niemeyer) * (Python committer) Date: 2013年04月24日 02:59
This simple script will spawn N Python interpreters that aren't properly collected due to the improper error handling:
import pty
for i in range(N):
 try: pty.spawn(["/non-existent"])
 except: pass
msg228264 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2014年10月02日 22:09
Can a linux guru comment on this please.
msg252445 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2015年10月07日 02:20
The spawn() function has this code outside of any error handler:
pid, master_fd = fork()
if pid == CHILD:
 os.execlp(argv[0], *argv)
If fork() succeeds, there will actually be a parent Python process and a child Python process. If exec() then fails, an exception will escape the spawn() function in the child process, while the parent process will carry on as if all is well. Maybe it would be worthwhile studying how the "subprocess" module handles exec() failure in the child process.
msg285300 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2017年01月12日 10:48
The patch for Issue 26228 proposes an improvement to the situation, although it is not perfect and does not include a test. I wonder if it is possible to replace fork() and execlp() with a subprocess.Popen invokation, at least in a new Python release?
History
Date User Action Args
2022年04月11日 14:57:44adminsetgithub: 62024
2017年01月12日 21:01:10BreamoreBoysetnosy: - BreamoreBoy
2017年01月12日 10:48:45martin.pantersetmessages: + msg285300
2015年10月07日 02:20:17martin.pantersetnosy: + martin.panter

messages: + msg252445
stage: needs patch
2014年10月02日 22:09:38BreamoreBoysetnosy: + BreamoreBoy

messages: + msg228264
versions: + Python 2.7, Python 3.4, Python 3.5, - Python 3.3
2013年04月24日 02:59:30niemeyercreate

AltStyle によって変換されたページ (->オリジナル) /