Time::Local busted?
- From: Mark Seger <Mark.Seger@xxxxxx>
- Date: Thu, 24 Apr 2008 09:00:45 -0400
I have a script that tails a file and on a SIGTERM I want it to exit. Sounds simple enough. It traps the signal, executes an 'exit', and then hangs! The real odd thing is one of the modules I'm 'using' is Time::Local. If I comment it out the script exits on SIGTERM and if it leave it in it doesn't. The only way I was able to figure this out was methodically removing pieces of code until it worked correctly and as you might guess, the last thing I thought of was removing some of the 'use' statements. Anyhow this leads to a few questions:
- does anyone have a clue what this is breaking things?
- how would you have tracked down this problem with the Time module
- how can I make this work correctly AND use Time?
Anyhow, here's a pretty small piece of code that fails! Just comment out the 'use Time' and it works...
#!/usr/bin/perl -w
use strict;
use Time::Local;
print "PID: $$\n";
$SIG{"TERM"}=\&sigTerm; # default kill command
while(1) {
open TAIL, "tail -f /var/log/aggregate|" or die;
while (my $line=<TAIL>) {
my $x=1;
}
}
sub sigTerm {
print "SIGTERM\n";
exit(1);
}
here's what I see when I execute a 'kill' from another window:
[root@cag-dl380-01 tmp]# ./test9.pl
PID: 13796
SIGTERM
and it's hung... Now if I comment out Time:
[root@cag-dl380-01 tmp]# ./test9.pl
PID: 13799
SIGTERM
[root@cag-dl380-01 tmp]#
-mark
.
- Follow-Ups:
- Re: Time::Local busted?
- From: Ben Morrow
- Re: Time::Local busted?
- From: xhoster
- Re: Time::Local busted?
- From: smallpond
- Re: Time::Local busted?
- Prev by Date: Re: FAQ 5.3 How do I count the number of lines in a file?
- Next by Date: FAQ 2.6 What modules and extensions are available for Perl? What is CPAN? What does CPAN/src/... mean?
- Previous by thread: A noob playing with: Divert sockets, Linux and Perl.
- Next by thread: Re: Time::Local busted?
- Index(es):
Relevant Pages
|
|