# # patch "ChangeLog" # from [8c9debc779c7c4afe63fe32095a4b7d1bdde9147] # to [0b804900fd63d2a94549afda5fbff8c17c469993] # # patch "contrib/monotone-notify.pl" # from [7b80bc10043bcd080e0a98742cd49a3c8aa7b8df] # to [5fe63044551809be3609ccdd179c51b68109ffb1] # --- ChangeLog +++ ChangeLog @@ -1,3 +1,9 @@ +2005-04-17 Henrik Holmboe + + * contrib/monotone-notify.pl: Add signal handlers. Correct some + typos. + (my_exit): New function that does a cleanup and exit. + 2005-04-17 Olivier Andrieu * transforms.cc: fix glob_to_regexp assertions --- contrib/monotone-notify.pl +++ contrib/monotone-notify.pl @@ -73,6 +73,11 @@ 'quiet' => \$quiet, 'debug' => \$debug) or pod2usage(2); +$SIG{HUP} = \&my_exit; +$SIG{KILL} = \&my_exit; +$SIG{TERM} = \&my_exit; +$SIG{INT} = \&my_exit; + ###################################################################### # Respond to user input # @@ -97,7 +102,7 @@ pod2usage(2); } if (!defined $difflogs_to && !defined $nodifflogs_to) { - my_errlog("You need to specify a To address with --to"); + my_errlog("You need to specify a To address with --diffslogs-to or --nodiffslogs-to"); pod2usage(2); } } @@ -140,12 +145,15 @@ my $remove_workdir = 0; if (!defined $workdir) { - $workdir = "/var/tmp/monotone_motify.work.$$"; + $workdir = "/var/tmp/monotone_notify.work.$$"; mkdir $workdir; $remove_workdir = 1; } elsif (! file_name_is_absolute($workdir)) { $workdir = rel2abs($workdir); } +if (! -d $workdir && ! -w $workdir && ! -r $workdir) { + my_error("work directory $workdir not accessible, exiting"); +} my_debug("using work directory $workdir"); my_debug("(to be removed after I'm done)") if $remove_workdir; @@ -448,13 +456,8 @@ ###################################################################### # Clean up. # -my_log("cleaning up."); -unlink @files_to_clean_up; -rmdir $workdir if $remove_workdir; +my_exit(); -my_log("all done."); -exit(0); - ###################################################################### # Subroutines # @@ -594,6 +597,17 @@ return $return; } +# my_exit removes temporary files and gracefully closes network +# connections. +sub my_exit +{ + my_log("cleaning up."); + unlink @files_to_clean_up; + rmdir $workdir if $remove_workdir; + my_log("all done."); + exit(0); +} + # my_backtick does the same thing as backtick commands, but will print a bit # of debugging output when $debug is true. It will also die if the subprocess # returned an error code. @@ -738,7 +752,7 @@ two files F and F will be left in the work directory. -The default working directory is F, +The default working directory is F, and will be removed automatically unless F or F are left in it.