Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How to kill an external program

by BronzeWing (Monk)
on Jan 13, 2003 at 19:33 UTC ( #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? | Other CB clients
Other Users?
Others exploiting the Monastery: (2)
As of 2023-02-07 01:33 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (38 votes). Check out past polls.

    Notices?