<?xml version="1.0" encoding="windows-1252"?>
<node id="982720" title="Kill a process in perl windows and proceed only if it killed the process" created="2012-07-19 17:35:22" updated="2012-07-19 17:35:22">
<type id="115">
perlquestion</type>
<author id="961">
Anonymous Monk</author>
<data>
<field name="doctext">
Hello- &lt;br&gt;&lt;br&gt;I would like to kill a processid in perl and I want to verify whether it actually killed the process. If it fails I need to try it again one more time otherwise exist. &lt;br&gt;
Is Win32::Process::KillProcess is the best method to kill a process in perl for an application running on windows environment?&lt;br&gt;

Will KillProcess return true on success?&lt;br&gt; 
what this exit code means will that tells me it was a success? &lt;br&gt;
How can I check with an exitcode or returnCode and make sure a process acually killed?&lt;br&gt;

&lt;code&gt;
should I call
TRYAGAIN:
my $exitcode = 0;
my $count = 0;
Win32::Process::KillProcess($pid, $exitcode);
# is the method just issue the kill command here and moving # or is it really waits until the process gets killed?
if ($exitCode != 1) { # is this a right check?
    ++$count;
   if ($count == 2) { 
       print "Error: Failed Killing: " . $pid; 
       exit;
   }
   goto TRYAGAIN
}
&lt;/code&gt;</field>
<field name="reputation">
17</field>
</data>
</node>
