Kelly Robbins wrote: > Roger, > > How much work is considered a lot? There are 4 lines to the signal > handler... 1 to print the fact that I made it there :), 1 to put together > an output string, and 2 calls to a procedure (about 10 lines) to spit out > some html output. > > Kelly
According to what i have read, that may be too musch. Mucking around with memory structures in a sig handler can confuse perl if the changes made inside the sig handler confict with what perl was doing befor it caught the sig (updating or deleting that memory structure - I am not a guts person so I proboly said that wrong...) anyway, the book recomends just throwing a die() or seting a global flag in the sig handler and then checking for that flag in the "if ($@)" block and doing all your real work there. You might try moveing the warning, the procedure calls, and the string creation into the "if ($@)" block and seeing if that make stuff more stable. You might also try your code on different versions of perl - I think 5.6.1 addressed some sig handler issues, but I am not sure. Roger > > > On Tue, 5 Mar 2002, Roger Grayson wrote: > > >>Kelly Robbins wrote: >> >>>Tim, >>> >>>This is exactly the example that I used. I can get the program to run for >>>a few iterations, and handle a few timeouts, but it eventually seg >>>faults. :( >>> >>>I'm including the output generated from print statements in my script. It >>>shows a few iterations, a few timeouts, then a seg fault. I can get the >>>signal to work, but the seg fault over time is what I'm concerned about. >>>Any suggestions for this? >>> >>>At CheckTNSPing >>>At CheckDiskSpace >>>Timeout while performing DiskSpace alert >>>Sleeping for 5 seconds starting @ 2002/03/05 17:01:47. >>>At CheckTNSPing >>>At CheckDiskSpace >>>At CheckSessionInfo >>>At CheckInvalidRows >>>At CheckPermissions >>>Timeout while performing Permissions alert >>>Sleeping for 5 seconds starting @ 2002/03/05 17:02:08. >>>At CheckTNSPing >>>At CheckDiskSpace >>>Timeout while performing DiskSpace alert >>>Sleeping for 5 seconds starting @ 2002/03/05 17:02:22. >>>At CheckTNSPing >>>At CheckDiskSpace >>>At CheckSessionInfo >>>At CheckInvalidRows >>>At CheckPermissions >>>At CheckMaxParameters >>>At CheckObjectExtents >>>Timeout while performing ObjectExtents alert >>>Sleeping for 5 seconds starting @ 2002/03/05 17:02:43. >>>At CheckTNSPing >>>At CheckDiskSpace >>>zsh: 11968 segmentation fault /usr/local/bin/perl5 >>>/usr/vendor/oracle/UU-DBA/cr >>>on/../bin/OracleMonitor -s >>> >>> >>>On Tue, 5 Mar 2002 [EMAIL PROTECTED] wrote: >>> >>> >>> >>>>Kelly, >>>> >>>>I think that what you want to achieve can be done with the alarm() function. >>>>If you use it in an eval block, it won't kill the program. Here's a simple >>>>example (from "Perl: The Complete Reference" by Martin Brown, pg 455): >>>> >>>> print "Your name is? :\n"; >>>> eval >>>> { >>>> local $SIG{ALRM} = sub { die "Timeout" }; >>>> alarm(10); >>>> $name = <STDIN>; >>>> chomp $name; >>>> alarm 0; >>>> }; >>>> >>>> if ($@ and $@ =~ /Timeout/) { $name = 'Anonymous' } >>>> print "Hello $name!\n"; >>>> >>>>alarm(10) sets the alarm for 10 seconds. alarm(0) turns it off. The special >>>>variable $@ aka $EVAL_ERROR will be empty if the eval execute without error, >>>>otherwise it holds the "die" message. >>>> >>>>There is also a good discussion of this stuff in the O'Reilly book >>>>"Programming Perl". >>>> >>>>Hope this helps, >>>> >>>>Tim Helck >>>> >>>>-----Original Message----- >>>>From: Kelly Robbins [mailto:[EMAIL PROTECTED]] >>>>Sent: Tuesday, March 05, 2002 12:17 PM >>>>To: [EMAIL PROTECTED] >>>>Subject: Signal to timeout a long running query >>>> >>>> >>>> >>>>I'm trying to incorporate a signal in a database monitoring tool that we >>>>have written which runs "forever". I would like to be able to break out >>>>of a long running query, but I would also like the script to continue >>>>running. >>>> >>>>I have been successful writing a signal to quit a query that is running to >>>>long, and the script will then continue, but the script eventually seg >>>>faults over time. Is there any way to prevent the seg faults? If not, is >>>>there a better way of imposing a timeout on my queries? >>>> >>>>Kelly >>>> >>>> >>>> >>>> >>Kelly, >> >>How much work is your signal handler doing? Lincoln mentions in "Network Programming >with Perl" that >>sig handlers can cause segfaults if you do a lot of work in them. So if you are >doing more than just >>calling die() or setting a global var in your sig handler that could be the problem. >It might also >>matter which version of perl you are using. >> >>Roger >> >>-- >>There are lies, there are damned lies, and there are the power point presentations >you make up to >>explain your code. >> >> > > -- There are lies, there are damned lies, and there are the power point presentations you make up to explain your code.