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.

Author eli.bendersky
Recipients Aneesh, Peter.Caven, brian.curtin, eli.bendersky, georg.brandl, kbk, loewis, ned.deily, sunqiang, terry.reedy, tim.golden, vstinner
Date 2011-07-29.06:04:12
SpamBayes Score 4.7538154e-07
Marked as misclassified No
Message-id <1311919454.19.0.726531087484.issue12540@psf.upfronthosting.co.za>
In-reply-to
Content
Terry,

""" When I tried the same fix in idlelib/PyShell.py, adding 'import subprocess' and changing
        self.rpcpid = os.spawnv(os.P_NOWAIT, sys.executable, args)
to
        self.rpcpid = subprocess.Popen(args).pid
(args begins with sys.executable) IDLE failed to start. The only evidence that it had been invoked was a brief (1/4 second?) appearance of 1 pythonw process in task manager. On a subsequent tries, without touching the file, I do not see even that. Is there any obvious mistake in the above? """

No, when I do the same, things seem to go fine. No zombie is left running after IDLE is closed, and even "Restart shell" works without leaving a zombie.

Maybe you had other modifications in your idlelib sources? 

Anyway, this wouldn't be a complete fix, because in:

    def unix_terminate(self):
        "UNIX: make sure subprocess is terminated and collect status"
        if hasattr(os, 'kill'):
            try:
                os.kill(self.rpcpid, SIGTERM)
            except OSError:
                # process already terminated:
                return
            else:
                try:
                    os.waitpid(self.rpcpid, 0)
                except OSError:
                    return

os.waitpid on Windows also expects a process handle, not pid. 

I think the complete solution, in addition to replacing os.spawnv by subprocess.Popen, would be to use Popen.kill and then Popen.wait instead of os.kill and then os.wait in the code above. This would require keeping the Popen object somewhere in self.
History
Date User Action Args
2011-07-29 06:04:14eli.benderskysetrecipients: + eli.bendersky, loewis, georg.brandl, terry.reedy, kbk, vstinner, tim.golden, ned.deily, brian.curtin, sunqiang, Peter.Caven, Aneesh
2011-07-29 06:04:14eli.benderskysetmessageid: <1311919454.19.0.726531087484.issue12540@psf.upfronthosting.co.za>
2011-07-29 06:04:13eli.benderskylinkissue12540 messages
2011-07-29 06:04:12eli.benderskycreate