Hi everyone! So I'm trying to make sure NFS shares are properly mounted by using a small perl script, along side a much larger program. It uses utime(undef,undef,"/pathtoshare") to make sure the path is still accessible. I've tried to wrap the utime function in an alarmed eval without success. It seems alarm doesn't get signaled. Example: - Mount client to NFS share - run test.pl - OK - stop nfs service on server - run test.pl - flop without alarm (waits about 120 seconds) Here is the relevant portion of the code.
print "Evaluating... \n"; eval{ local $SIG{ALRM} = sub { $sys_check_mount{$mount_server} = 0; print "Alarm!"; exit(); }; alarm(5); print "Alarm Set... Trying system commands... \n"; if (-e $mount_server_check_path && utime(undef, undef, "$moun +t_server_check_path/mount_check")){ #print "OK\n"; $sys_check_mount{$mount_server} = 1; }else{ #print "Broken\n"; $sys_check_mount{$mount_server} = 0; push (@mount_server_broken,$mount_server); } alarm(0); print "Reset Alarm... \n"; } }
Ideally the script shouldn't exit, but rather return something from the eval but I'm not sure how to return from the local $SIG{ALRM}... Any help would be greatly appreciated :)

In reply to Alarm and blocking I/O. by expresspotato

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.