git: a7a3eec3fc37 - stable/14 - mail: remove the SIGHUP handler from lex.c

From: Dag-Erling Smørgrav <des_at_FreeBSD.org>
Date: Wed, 21 May 2025 17:47:37 UTC
The branch stable/14 has been updated by des:

URL: https://cgit.FreeBSD.org/src/commit/?id=a7a3eec3fc37044467551a7e2bb00d9a1388f6b7

commit a7a3eec3fc37044467551a7e2bb00d9a1388f6b7
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2025-05-14 19:20:16 +0000
Commit:     Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-05-21 17:33:09 +0000

    mail: remove the SIGHUP handler from lex.c
    
    If the command is simply going to exit without doing any cleanup, then
    an immediate exit(3) does not add any value and in-fact obscures that
    the program was terminated by a signal.
    
    This is motivated by POSIX conformance requirements, but it's also a
    little bit of a tidy-up.  Some investigation into the history of mail(1)
    shows that, at one point, hangup() would attempt to save messages into
    mbox before exiting.  It was later transformed into a simple exit() and
    likely could have been GC'd at that point.
    
    Reviewed by:    des, emaste, ivy
    Sponsored by:   Klara, Inc.
    Differential Revision:  https://reviews.freebsd.org/D50247
    
    (cherry picked from commit df16cbdcf1927200eb910c1874faee6f3d8b9a97)
---
 usr.bin/mail/extern.h |  1 -
 usr.bin/mail/lex.c    | 13 -------------
 2 files changed, 14 deletions(-)

diff --git a/usr.bin/mail/extern.h b/usr.bin/mail/extern.h
index 669c10b91beb..24ea67939ff2 100644
--- a/usr.bin/mail/extern.h
+++ b/usr.bin/mail/extern.h
@@ -133,7 +133,6 @@ int	 getrawlist(char *, char **, int);
 uid_t	 getuserid(char *);
 int	 grabh(struct header *, int);
 int	 group(void *);
-void	 hangup(int);
 int	 hash(const char *);
 void	 hdrstop(int);
 int	 headers(void *);
diff --git a/usr.bin/mail/lex.c b/usr.bin/mail/lex.c
index b931d6e16a15..c5f4f26781ef 100644
--- a/usr.bin/mail/lex.c
+++ b/usr.bin/mail/lex.c
@@ -205,8 +205,6 @@ commands(void)
 	if (!sourcing) {
 		if (signal(SIGINT, SIG_IGN) != SIG_IGN)
 			(void)signal(SIGINT, intr);
-		if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
-			(void)signal(SIGHUP, hangup);
 		(void)signal(SIGTSTP, stop);
 		(void)signal(SIGTTOU, stop);
 		(void)signal(SIGTTIN, stop);
@@ -573,17 +571,6 @@ stop(int s)
 	}
 }
 
-/*
- * Branch here on hangup signal and simulate "exit".
- */
-void
-hangup(int s __unused)
-{
-
-	/* nothing to do? */
-	exit(1);
-}
-
 /*
  * Announce the presence of the current Mail version,
  * give the message count, and print a header listing.