From 6a40ecf6aec13bf650645d65713c0327c6d8c5e6 Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 8 Sep 2015 00:17:24 +0200 Subject: Block SIGINT signals to the children for type=tunnel. So we can clean after us (and for instance remove the lockfile). --- interimap | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'interimap') diff --git a/interimap b/interimap index 6442054..a94110b 100755 --- a/interimap +++ b/interimap @@ -51,10 +51,12 @@ sub usage(;$) { } exit $rv; } -usage(1) unless GetOptions(\%CONFIG, qw/config=s quiet|q target=s@ debug help|h repair delete rename/); + +my @COMMANDS = qw/repair delete rename/; +usage(1) unless GetOptions(\%CONFIG, qw/config=s quiet|q target=s@ debug help|h/, @COMMANDS); usage(0) if $CONFIG{help}; my $COMMAND = do { - my @command = grep {exists $CONFIG{$_}} qw/repair delete rename/; + my @command = grep {exists $CONFIG{$_}} @COMMANDS; usage(1) if $#command>0; $command[0] }; @@ -200,7 +202,8 @@ $DBH->do('PRAGMA foreign_keys = ON'); sub msg($@) { my $name = shift; return unless @_; - logger($name, @_) if defined $LOGGER_FD and $LOGGER_FD->fileno != fileno STDERR; + logger($name, @_) if defined $LOGGER_FD and defined $LOGGER_FD->fileno + and $LOGGER_FD->fileno != fileno STDERR; my $prefix = defined $name ? "$name: " : ''; print STDERR $prefix, @_, "\n"; } @@ -208,7 +211,8 @@ sub logger($@) { my $name = shift; return unless @_ and defined $LOGGER_FD; my $prefix = ''; - if ($LOGGER_FD->fileno != fileno STDERR) { + if (defined $LOGGER_FD and defined $LOGGER_FD->fileno + and $LOGGER_FD->fileno != fileno STDERR) { my ($s, $us) = Time::HiRes::gettimeofday(); $prefix = POSIX::strftime("%b %e %H:%M:%S", localtime($s)).".$us "; } -- cgit v1.2.3