I need a cleaner method than Win32::Process::Kill() to terminate a (non-perl) process I have spawned out of a perl script. It's a server that I want to start up, do some tests on and then cleanly shut down. I'm doing all of the management of this process with Win32::Process. The problem with this module's Kill() method is that it ultimately maps to win32's TerminateProcess(). This is bad because this blows the process out of the water, so to speak, without letting it clean up after itself. According to all the documentation I've read this can lead to possible problems with dll's used by the process, because it doesn't let the process properly disconnect from the dll's it is using. In the case of our server it also doesn't allow for flushing of the log buffer so we miss some diagnostic information.
It looks like the solution would be use the win32 GenerateConsoleCtrlEvent() to send a ctrl-c event to the process, but there doesn't seem to be a good way within the Perl world to access this function in the context I'm dealing with. Win32::Console does seem to implement some kind of access to this function, but the documentation there seems to indicate that it can only be used to send events to yourself (Not 100% sure of this as the documentation is rather limited).
This node seems to point to a way of using GenerateConsoleCtrlEvent using Win32::API, but this seems kludgy at best.
Does anyone know of a less kludgy solution to this problem?
--DrWhy
"If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."
In reply to How do I cleanly kill a spawned process on Win32. by DrWhy
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |