Please be specific to the 2 cases that I mentioned and tell me how can we tell which case's signals are safe and which case's are not, and most importantly WHY.

CASE 1:
#!/usr/bin/perl require 'myconfigure.cgi'; $timeout = 5; use DBI; $keywords = "Whether rocking natural-curls, a-short"; print "Content-type: text/html\n\n"; sub do_search { $time1 = time; $dbh=DBI->connect("dbi:mysql:$database:localhost","$username","$pa ssword"); $keywords_quoted = $dbh ->quote ($keywords); $query="SELECT count(*) FROM $websites_table WHERE MATCH(title) AG AINST ($keywords_quoted)"; $sth=$dbh->prepare(qq{$query}); $sth->execute(); $total_count = $sth->fetchrow_array (); $sth->finish; $dbh->disconnect ||die("Couldn't disconnect to database!\n"); $time2 = time; $time_ran = $time2 - $time1; } eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm $timeout; &do_search; alarm 0; }; if($@) { $time2 = time; $time_ran = $time2 - $time1; print "$@, Time Ran: $time_ran, Total Count: $total_count\n"; exit; } print "Time Ran: $time_ran, Total Count: $total_count\n"; exit;

CASE 2:
#!/usr/bin/perl $max_time = 5; $timeout = 3; use DBI; print "Content-type: text/html\n\n"; sub do_counter { $time1 = time; $time2 = time; $counter = 0; $time_ran = $time2 - $time1; $dbh=DBI->connect("dbi:mysql:$database:localhost","username","pass word"); $query="SELECT name FROM test"; $sth=$dbh->prepare($query); $sth->execute(); while ( @row = $sth->fetchrow_array ) { while($time_ran <= $max_time) { $conter++; $time2 = time; $time_ran = $time2 - $time1; } } $sth->finish; $dbh->disconnect ||die("Couldn't disconnect to database!\n"); } eval { local $SIG{ALRM} = sub { die "alarm\n" }; alarm $timeout; &do_counter; alarm 0; }; if($@) { print "$@, Time Ran: $time_ran, Counter: $conter\n"; exit; } print "Time Ran: $time_ran, Counter: $conter\n"; exit;

NOTES: I've a feeling you don't understand the issue in the thread, simply making empty statement.

In reply to Re^12: Perl Alarm Not Working by aceofspace
in thread Perl Alarm Not Working by aceofspace

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.