mail: tests: reset signal disposition before testing

As a good citizen of the OS, mail(1) won't try to catch signals that
were ignored when it started and it won't reconfigure its signal mask
unless it's going to try and handle a signal.  The test should start
mail(1) off in a well-known state for the signal that it's trying to
test in order to get the behavior that's desired.

No functional change, just improves the resilience of the test.

Reviewed by:	des
Sponsored by:	Klara, Inc.
Differential Revision:	https://reviews.freebsd.org/D50599
This commit is contained in:
Kyle Evans 2025-05-29 15:08:50 -05:00
parent 2e47009079
commit d5e5e24179

View file

@ -50,6 +50,17 @@ mailx_signal_test(int signo, bool interactive)
atf_tc_fail("failed to fork");
if (pid == 0) {
/* child */
sigset_t set;
/*
* Ensure mailx(1) will handle SIGINT; i.e., that it's not
* ignored or blocked.
*/
(void)signal(signo, SIG_DFL);
sigemptyset(&set);
sigaddset(&set, signo);
ATF_REQUIRE_INTEQ(0, sigprocmask(SIG_UNBLOCK, &set, NULL));
dup2(ipd[0], STDIN_FILENO);
close(ipd[0]);
close(ipd[1]);