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;
}
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|