On Tue, Apr 9, 2013 at 11:15 PM, Mike Flannigan <mikef...@att.net> wrote:

>
> On 4/9/2013 6:10 AM, Jonathan Harris wrote:
>
>> Hi All
>>
>> I am using Strawberry Perl (latest release) on a Windows 2003 SP2 server
>>
>> I am trying to use a script to look at running processes, look for a
>> specific process, and kill that process if it is alive for more than 4
>> minutes as this would mean that the process has hung
>>
>> When testing killing Notepad or Firefox, it works fine
>> In practice when trying to kill "ovntag or oprop" processes, it doesn't
>>
>> It uses the following to kill the process:
>>
>> Win32::Process::KillProcess ($pid, \$exitcode);
>>
>> So here's the question.
>> Is there a difference between killing a process that is alive and one that
>> has hung?
>> In theory a process is a process, right?!
>> But the hanging process does not die!
>>
>> Is there a better way to kill a process so that a hanging process will
>> actually die?
>>
>> Thanks in advance
>>
>> Jon
>>
>
>
> It's highly unlikely this will fix your problem, but
> I will throw it out for consideration:
>
> $ProcessObj->Kill( $exitcode )
>        Kill the associated process, have it terminate with exit code
>        $ExitCode
>
>
> Mike
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscr...@perl.org
> For additional commands, e-mail: beginners-h...@perl.org
> http://learn.perl.org/
>
>
>
Hi Mike

Many thanks for your response

I updated this post yesterday with a revised subject (Win32 - Killing
Processes - Update Possible Solution ) - probably should have kept it all
on the same thread!

I did try what you suggested, but with not much luck

Instead as an option I am testing a fix, using a system call to Windows to
force quit the process

system 'taskkill /f /PID ' . ($new_pid);

As anyone who has used windows has probably experienced before, when trying
to use task manager to quit a hung process, the 'end process' button
doesn't always do the job first time around and can often require multiple
clicks!
I have the feeling that this process gets itself into that state, so a
single call from the Win32 module is probably insufficient

However, using taskkill on the cli with the 'force' argument has a far
higher success rate - hence the system call

Hopefully this will solve the issue!
If you can think of anything else at all, I'm all ears and grateful for any
input!

Thanks again

Jon

Reply via email to