> -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of > Robert Blayzor > Sent: maandag 7 maart 2005 15:39 > To: ClamAV users ML > Subject: Re: [Clamav-users] ClamAV 0.83 - Stream scanning timeout > > > I'll give it a whirl, and yes, I seem to have it trapping error > conditions. (unless something changed, this always worked) > > eval { > local $SIG{ALRM} = sub { die "Stream timeout"; }; > alarm $sc{TIME_OUT}; > while(<$csock>) { > if (/(\S+)\ FOUND$/) { > $vs = $1 unless ($vs); > $vf++; > } > $err = $1 if ($r =~ /^ERROR\:(.*)/); > } > alarm 0; > }; > $err = $@ if($@); >
Perl signals are not always as local as they may seem. :) You really might want to reset the alarm after the eval {} loop as well (in case you break out uncleanly from it). Consider the following: ------------------------------- #!/usr/local/bin/perl sub clam_test { eval { local $SIG{ALRM} = sub { die "Timeout\n" }; alarm 2; }; } clam_test (); print "Back!\n"; sleep 4; print "Made it past the signal!\n"; exit 0; ------------------------------- You'll never get "past the signal" here (Perl 5.8.6). Nor here: ------------------------------- #!/usr/local/bin/perl sub clam_test { eval { local $SIG{ALRM} = sub { die "Timeout\n" }; alarm 2; die "Oops!\n"; }; } clam_test (); print "Back!\n"; sleep 4; print "Made it past the signal!\n"; exit 0; ------------------------------- - Mark _______________________________________________ http://lurker.clamav.net/list/clamav-users.html