BEGIN { sub wahn { open( F, ">> wahn.log" ); # ;) truncate( F, 0 ) if ( (stat( F ))[7] > 1024*1024 ); # > 1 MByte flock( F, 2 ); my $s = localtime; print F $s; print F ' [WARN]'; foreach (@_) { print F " $_" } print F "\n"; close ( F ); } sub dai { open( F, ">> wahn.log" ); truncate( F, 0 ) if ( (stat( F ))[7] > 1024*1024 ); # > 1 MByte flock( F, 2 ); my $s = localtime; print F $s; print F ' [DIE]'; foreach (@_) { print F " $_" } print F "\n"; close ( F ); } $SIG{_ _DIE_ _} = \&dai; $SIG{_ _WARN_ _} = \&wahn; }