Well in fairness my original question wasn't why "won't alarm work", this thread has just gone that way so I've addressed the suggestions given.

It's hard to provide more detail than I already have...

The program I'm struggling in is rather big, here it is again but with the WMI server probing line included and sql queries changed for @array values to simplify.

use strict; use Win32::OLE qw (in); my @servers=('servera','serverb','serverc'); foreach(@servers) { my $server=$_; $server=~s/^\s+|\s+$//g; my $namespace="\\root\\cimv2"; my $object=Win32::OLE->GetObject( "winmgmts:{impersonationLevel=impe +rsonate,(security)}//".$server.$namespace );} or die "could not get o +bject"; # NOW GET DRIVE INFO THROUGH WMI }
The script goes to each server in turn, tries to initiate a WMI connection and fails on one server at the my $object line, due to some issue with the server. Instead of timing out the script just hangs there... forever. Hence the need for a script to somehow prevent this happening.

I am not asking for a solution including alarm, I've already explored using alarm to some depth, however I'm very willing to explore it further when suggestions pop up, i.e. the Time::HiRes one. I did try Win32::Process with the idea that the child could signal its parent after a set amount of time (as a substitue to alarm) but I couldn;t get the parent to seccussfully recieve a signal from it's child process.


In reply to Re^2: simple timeout by disciple01
in thread simple timeout by disciple01

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.