Time::Local busted?



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
.



Relevant Pages

  • Re: How do I properly use global variables?
    ... I'd like my program below to change $status to zero to exit the loop. ... When script is running,how can you re-run it with another argument to ... When you run it,you can send SIGINT or SIGTERM to let it exit gracefully. ...
    (perl.beginners)
  • Re: How do I properly use global variables?
    ... I'd like my program below to change $status to zero to exit the loop. ... When you run it,you can send SIGINT or SIGTERM to let it exit gracefully. ... The script would print "out of loop. ...
    (perl.beginners)
  • Re: VB script skelleton
    ... > I'm interested in writing a short script that executes ... > as background jobs because they both never exit, ...
    (microsoft.public.scripting.vbscript)
  • Re: Crontab: Do something exactly every 3 week on Tuesday?
    ... Anonymous Sender wrote: ... BM> Run the script every week, but have it keep a counter in a file. ... Every BM> time the counter reaches 3 it executes the command, then sets it back to 0 ... If not, exit. ...
    (comp.os.linux.misc)
  • Re: Changing a users password non-interactively?
    ... You need expect and a setpass.expect script which ill add ... exit with a nasty warning. ... # Be careful of the COMMAND and UNDOCMD - they are dependant on your ...
    (comp.unix.aix)