[python-win32] Strange issue with killing a process

stephen stephen at theboulets.net
Mon Oct 20 11:18:01 EDT 2003


I can kill a program this way:

import os, win32api, sys,os.path

base = "C:\\Program Files\\XEmacs\\XEmacs-21.4.13\\i586-pc-win32"
prog = "xemacs.exe"
command = os.path.join(base,prog)
mode = os.P_NOWAIT
id = os.spawnl(mode,command)
win32api.TerminateProcess(id,0)

But, and here's what's strange, this will only work if called from the same
script. When I pickle 'id' and exit the script without killing the process, I
can't start another script that would unpickle 'id' and then kill the process.
Trying to do so gives me this error:

Traceback (most recent call last):
  File "killprocess.py", line 20, in ?
    win32api.TerminateProcess(id,0)
pywintypes.error: (6, 'TerminateProcess', 'The handle is invalid.')

Anyone know what's going on?

_________
Stephen



More information about the Python-win32 mailing list