Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re: How do I cleanly kill a spawned process on Win32.

by weismat (Friar)
on Feb 26, 2009 at 07:16 UTC ( #746468=note: print w/ replies, xml ) Need Help??


in reply to How do I cleanly kill a spawned process on Win32.

Have a look at the following example using Win32::OLE to stop a process.
http://techtasks.com/code/viewbookcode/569
You could also check what the normal "kill" command maps to.


Comment on Re: How do I cleanly kill a spawned process on Win32.
Re^2: How do I cleanly kill a spawned process on Win32.
by DrWhy (Chaplain) on Feb 26, 2009 at 10:07 UTC
    I looked at the example you mention, and a little more poking around in WMI docs on the Web. I can't tell for sure, but I strongly suspect that the Win32::OLE method degenerates to TerminateProcess(), so that wouldn't solve the problem.

    I've looked at the source code for Perl 5.8.9, and I think I found the answer to your suggestion about perl's builtin kill(). I'm far from an expert so this is only a guess. In win32.c there's a function my_kill() that seems to be the core of the implementation of perl's builtin kill() on Windows platforms. It looks like they are trying to emulate some of the more common signals from *nix land so that if you were to kill 2, $pid it would call GenerateConsoleCtrlEvent(CTRL_C_EVENT,pid), kill 9, $pid would map to TerminateProcess(pid), (0, 1, SIGBREAK and SIGTERM are also handled specially). So this could potentially work for me, by just doing a kill 2, $pid, but I'm not sure since I'm not that familiar with Perl's guts and I haven't seen any documentation to confirm this behavior.

    --DrWhy

    "If God had meant for us to think for ourselves he would have given us brains. Oh, wait..."

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://746468]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2014-07-26 15:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (178 votes), past polls