[issue14252] subprocess.Popen.terminate() inconsistent behavior on Windows

Dave Abrahams report at bugs.python.org
Sun Mar 11 17:02:48 CET 2012


New submission from Dave Abrahams <dave at boostpro.com>:

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'

----------
components: Library (Lib)
messages: 155391
nosy: dabrahams
priority: normal
severity: normal
status: open
title: subprocess.Popen.terminate() inconsistent behavior on Windows
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14252>
_______________________________________


More information about the Python-bugs-list mailing list