[python-win32] Understanding "Access Denied" when calling win32process.TerminateProcess() from Run As Administrator prompt
Tony Cappellini
cappy2112 at gmail.com
Thu Nov 14 03:01:11 CET 2013
>>Well, slightly oddly, this is the error message you receive when you try
> >>to terminate a process which has already terminated! I don't know if
> >>this behaviour is new to Win7 (and I'm reluctant to build a WinXP VM
> >>just to test one line of code :) ).
>
> >>Could that be the answer?
>
>
>
Sorry for the delay in replying, had a few more important crises to solve.
To summarize, I have a program running under Windows XP, which launches a
process
via os.spawnv(). When the user wants to exit the program they press Ctrl-C.
The program terminates the process via win32process.TerminateProcess().
Everything is normal.
Running under Windows 7, (using the same version of Python), an exception
is raised when
win32process.TerminateProcess() is called. I know know the reason why
Yes Tim, you're right about this. The external process I was trying to
terminate
with win32process.TerminateProcess() has already been terminated (when
running under Windows 7)
I wrote a short program which duplicated my application and the external
process,
to investigate this issue.
The application launches a process. The process does nothing but count
from 0- infinity.
The count is displayed on the screen 1 second apart.
The application sits in a while loop waiting for Ctrl-C to be pressed.
When I press Ctrl-C, using Windows 7 Task Manager I can see one of the two
python processes
terminate. Print statements in my code tells me it's the external process
which is displaying a count every 1 second.
The things I don't understand are:
1. Under Windows XP, the Ctrl-C does not terminate the process, and
win32process.TerminateProcess() must be called.
2. Under Windows 7, Ctrl-C DOES terminate the process, and win32process.
TerminateProcess()
should not be called.
3. How (and why) does the Ctrl-C get propagated to the process, and why
does it terminate the process, when the process is running in a separate
address space?
Thanks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-win32/attachments/20131113/f805158f/attachment.html>
More information about the python-win32
mailing list