Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How do I kill a process tree in Windows

by JSchmitz (Canon)
on Aug 18, 2005 at 18:59 UTC ( #484929=note: print w/ replies, xml ) Need Help??


in reply to How do I kill a process tree in Windows

The below example is from a Win 2000 server. You should be able to use kill "process name" and it should smoke everything in the tree. Similar to "pkill" in Solaris. I am not a Win admin so I am not sure if they don't have some extra command line kit like ptools installed here or what but you may want to check into it.....(updated) In windows 2003 you have to use: tskill "process ID"

c:\kill bpsched process bpsched.exe (860) - '' killed process bpsched.exe (852) - '' killed process bpsched.exe (4168) - '' killed
Cheers -
Jeffery


Comment on Re: How do I kill a process tree in Windows
Download Code
Re^2: How do I kill a process tree in Windows
by DrWhy (Chaplain) on Aug 18, 2005 at 20:21 UTC
    So it sounds like you are saying there is no way to do it inside perl; I'll have to go to an external program. I didn't find anything named kill(\.exe)? on my XP box. A little research indicates that this was a tool that came with WIn2k, but not more recent OSs. I did find someone who had taken the code for that kill and updated to work with XP and to handle process trees. That's here.

    I'm still kind of hoping there's a good Perl solution out there so I don't have to be starting up external processes in a SIGINT handler. I took a second look at Proc::Killfam just in case it might work under Windows even if it isn't available via ppm. There seems to be some Cygwin compatibility in Proc::ProcessTable (which Proc::Killfam uses to figure out what processes need to be killed), but I don't know if that translates into Windows compatibility for P::K. I'm thinking not.

    --DrWhy

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

      Unfortunately I don't know the answer to the Perl topic, however the builtin utility you want on XP is called "taskkill". Passing it the /T parameter is a treekill.
      Hi,

      If you spawn the processes yourself from within a perl script you should use Win32::Job . This will give you job control and thus the ability to kill a group of process.

      As i understand it, this is the way to control processes in Windows, that is killing a processes and all itīs sons.

      I find dealing with PID and PPIDS is kind of not adapted since PIDs numbers are recycled fastly and you could kill something else !

      In "real" windows programing there may be something like a "process handle" that you get when you create a process and that allow fine control, but within Perl Win32::Job seems the way to go ...

      ZlR.

        This looks great, except the processes I'm trying to kill are started from within another module (Test::Harness). In order to use this I would have to modify Test::Harness, which is just not going to happen... I'll look into taskkill mentioned by the anonymous monk above.

        --DrWhy

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

      It's called a RESOURCE KIT, and you get it on CD with servers(usually), and can download it from microsoft Resource Kit

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-10-22 23:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (122 votes), past polls