On 14/11/2013 02:01, Tony Cappellini wrote: > 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)
[...] > 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? This is a quick answer to say: unfortunately, Ctrl-C propagation on Windows within Python itself and between processes in general is a small nightmare! This is only complicated by the fact that you're using the CRT spawn which does things under-the-covers to attempt to simulate Posix semantics -- making it harder to reason about without pretty much stepping through the code. Hopefully someone else has (a) more time right now and/or (b) more knowledge at their fingertips to give you a better answer. If no-one else comes back I'll try to dig up more information. Ultimately, though, the answer might be: you'll just have to cope with it! TJG _______________________________________________ python-win32 mailing list python-win32@python.org https://mail.python.org/mailman/listinfo/python-win32