Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: Die silently?

by gg48gg (Sexton)
on Feb 20, 2013 at 20:10 UTC ( #1019839=note: print w/ replies, xml ) Need Help??


in reply to Die silently?

This is an awesome thread, especially the 'fart' code and the explanations of it. I recently ran into this "die quietly" issue using the below code. I was getting unwanted "\n"'s inserted that I could not explain. I ended up removing the "die" statement and it works as I want, but I am not sure if I am doing something incorrect (not killing my system command?). This is really my first attempt in using a timed out system command via eval/alarm. Here is my code if you care to review it and give me some feedback.

sub get_size { my $disk=$_[0]; my $size; eval { local $SIG{ALRM} = sub { print_debug("get_size timed out for device $disk"); die; }; alarm(4); $size=qx(bootinfo -s $disk 2>/dev/null); alarm(0); }; $size=($size)? $size : "unknown"; chomp $size; return $size; }


Comment on Re: Die silently?
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1019839]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (5)
As of 2015-07-04 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls