git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 2/2][Perlers?] git-send-email: SIG{TERM,INT} handlers

From
Michael Witten <mfwitten@mit.edu>
Date
Feb 2, 2008, 04:06 UTC
Message-ID
<1201925161-9864-2-git-send-email-mfwitten@mit.edu>
In-Reply-To
<1201925161-9864-1-git-send-email-mfwitten@mit.edu>

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>
---
	Perlers, please comment.
 git-send-email.perl |   25 +++++++++++++++++++++++--
 1 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/git-send-email.perl b/git-send-email.perl
index ed0a473..a0c9e8f 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -24,8 +24,6 @@ use Data::Dumper;
 use Term::ANSIColor;
 use Git;
 
-$SIG{INT} = sub { print color("reset"), "\n"; exit };
-
 package FakeTerm;
 sub new {
 	my ($class, $reason) = @_;
@@ -201,6 +199,29 @@ my %config_settings = (
     "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:
 
-- 
1.5.4.rc5.17.g8ca921-dirty
Previous: Michael WittenNext: Junio C Hamano
Message 9 of 16 in “git-send-email: ssh/login style password requests”
  1. git-send-email: ssh/login style password requestsMichael Witten, Feb 1, 2008
  2. Junio C HamanoFeb 1, 2008
  3. Michael WittenFeb 1, 2008
  4. Michael WittenFeb 1, 2008
  5. Junio C HamanoFeb 1, 2008
  6. Michael WittenFeb 1, 2008
  7. Junio C HamanoFeb 2, 2008
  8. 1/2 [Perlers?] git-send-email: ssh/login style password requestsMichael Witten, Feb 2, 2008
  9. 2/2 [Perlers?] git-send-email: SIG{TERM,INT} handlersMichael Witten, Feb 2, 2008
  10. Junio C HamanoFeb 2, 2008
  11. Junio C HamanoFeb 2, 2008
  12. Michael WittenFeb 3, 2008
  13. Michael WittenFeb 3, 2008
  14. 1/3 [V.2] git-send-email: ssh/login style password requestsMichael Witten, Feb 4, 2008
  15. 2/3 [V.2] git-send-email: SIG{TERM,INT} handlersMichael Witten, Feb 4, 2008
  16. 3/3 [V.2] git-send-email: Better handling of EOF [^D]Michael Witten, Feb 4, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.