Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: How to kill an external program

by BronzeWing (Monk)
on Jan 13, 2003 at 19:33 UTC ( [id://226570]=note: print w/replies, xml ) Need Help??


in reply to How to kill an external program

The following code works for me. It assumes the process returns before it's done (I think all Win32 GUI programs do that, but command line ones don't - which sort are you using?).

my $PID = open my($Notepad), "|notepad.exe"; sleep 1; print "DIE!\n"; kill 9, $PID;

Perl Monks do it more than one way.

Replies are listed 'Best First'.
Re: How to kill an external program
by Anonymous Monk on Jan 13, 2003 at 22:03 UTC
    Thank you so much for your replies. I finally got it working with the Win32::Process. Here is what I came up with… Thanks again
    my $tempSleepMilSec = ($tempSleepSec * 1000); # amt of time to wait Win32::Process::Create($spiderProc, 'k:\\...\\spider.exe', "", 0, DETACHED_PROCESS, ".") || die ("can't create process: $!"); if ($spiderProc->Wait($tempSleepMilSec)) { print ("finished fine"); } else { print ("too long - killing"); my $tempKill = $spiderProc->Kill(0); }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (7)
As of 2024-03-28 18:56 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found