Skip to content

Commit

Permalink
git-send-email: SIG{TERM,INT} handlers
Browse files Browse the repository at this point in the history
A single signal handler is used for both SIGTERM and
SIGINT in order to clean up after an uncouth termination
of git-send-email.

In particular, the handler resets the text color (this cleanup
was already present), turns on tty echoing (in case termination
occurrs during a masked Password prompt), and informs the user
of of any temporary files created by --compose.

Signed-off-by: Michael Witten <mfwitten@mit.edu>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Michael Witten authored and Junio C Hamano committed Feb 5, 2008
1 parent 2363d74 commit 8742997
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions git-send-email.perl
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,6 @@
use Term::ANSIColor;
use Git;

$SIG{INT} = sub { print color("reset"), "\n"; exit };

package FakeTerm;
sub new {
my ($class, $reason) = @_;
Expand Down Expand Up @@ -201,6 +199,29 @@ sub format_2822_time {
"aliasesfile" => \@alias_files,
);

# Handle Uncouth Termination
sub signal_handler {

# Make text normal
print color("reset"), "\n";

# SMTP password masked
system "stty echo";

# tmp files from --compose
if (-e $compose_filename) {
print "'$compose_filename' contains an intermediate version of the email you were composing.\n";
}
if (-e ($compose_filename . ".final")) {
print "'$compose_filename.final' contains the composed email.\n"
}

exit;
};

$SIG{TERM} = \&signal_handler;
$SIG{INT} = \&signal_handler;

# Begin by accumulating all the variables (defined above), that we will end up
# needing, first, from the command line:

Expand Down

0 comments on commit 8742997

Please sign in to comment.