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 dabrahams
Recipients dabrahams
Date 2012-03-11.16:02:47
SpamBayes Score 2.098044e-12
Marked as misclassified No
Message-id <1331481768.76.0.379134642234.issue14252@psf.upfronthosting.co.za>
In-reply-to
Content
Try the following script on posix and Windows.  On Posix:

launched
. . . exiting
killed

on Windows:

launched
. . . exiting
Traceback (most recent call last):
  File "sp.py", line 16, in <module>
    p.terminate()
  File "c:\Python26\lib\subprocess.py", line 949, in terminate
    _subprocess.TerminateProcess(self._handle, 1)
WindowsError: [Error 5] Access is denied

This inconsistency seems unnecessary and is an obstacle to writing portable code.

from subprocess import *
import sys, time

p = Popen([sys.executable, '-c', '''
import time, sys
for i in range(3): 
    time.sleep(.3)
    print '.',
    sys.stdout.flush()
print 'exiting'
'''], stdout = sys.stdout, stderr = sys.stderr)

print 'launched'
time.sleep(2)

p.terminate()
print 'killed'
History
Date User Action Args
2012-03-11 16:02:48dabrahamssetrecipients: + dabrahams
2012-03-11 16:02:48dabrahamssetmessageid: <1331481768.76.0.379134642234.issue14252@psf.upfronthosting.co.za>
2012-03-11 16:02:48dabrahamslinkissue14252 messages
2012-03-11 16:02:47dabrahamscreate