git: 09bc6a5d5b33 - main - mail: Exit non-zero on failure to collect mail.
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Tue, 29 Apr 2025 15:12:40 UTC
The branch main has been updated by des:
URL: https://cgit.FreeBSD.org/src/commit/?id=09bc6a5d5b3333bc91e5f9fdf1e7bb282c4aea5a
commit 09bc6a5d5b3333bc91e5f9fdf1e7bb282c4aea5a
Author: Dag-Erling Smørgrav <des@FreeBSD.org>
AuthorDate: 2025-04-29 15:12:17 +0000
Commit: Dag-Erling Smørgrav <des@FreeBSD.org>
CommitDate: 2025-04-29 15:12:30 +0000
mail: Exit non-zero on failure to collect mail.
While here, avoid non-portable `pipe2()` in the regression test.
Fixes: 59597032c948
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D50069
---
usr.bin/mail/send.c | 4 +++-
usr.bin/mail/tests/mail_sigint_test.c | 5 +++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/usr.bin/mail/send.c b/usr.bin/mail/send.c
index b4fbd4cbfd8a..fe1086264a9c 100644
--- a/usr.bin/mail/send.c
+++ b/usr.bin/mail/send.c
@@ -293,8 +293,10 @@ mail1(struct header *hp, int printheaders)
* Collect user's mail from standard input.
* Get the result as mtf.
*/
- if ((mtf = collect(hp, printheaders)) == NULL)
+ if ((mtf = collect(hp, printheaders)) == NULL) {
+ senderr++;
return;
+ }
if (value("interactive") != NULL) {
if (value("askcc") != NULL || value("askbcc") != NULL) {
if (value("askcc") != NULL)
diff --git a/usr.bin/mail/tests/mail_sigint_test.c b/usr.bin/mail/tests/mail_sigint_test.c
index 76bf9b19b7f1..e2889493f3cd 100644
--- a/usr.bin/mail/tests/mail_sigint_test.c
+++ b/usr.bin/mail/tests/mail_sigint_test.c
@@ -39,7 +39,7 @@ mailx_sigint(bool interactive)
/* input, output, error, sync pipes */
if (pipe(ipd) != 0 || pipe(opd) != 0 || pipe(epd) != 0 ||
- pipe2(spd, O_CLOEXEC) != 0)
+ pipe(spd) != 0 || fcntl(spd[1], F_SETFD, FD_CLOEXEC) != 0)
atf_tc_fail("failed to pipe");
/* fork child */
if ((pid = fork()) < 0)
@@ -55,6 +55,7 @@ mailx_sigint(bool interactive)
dup2(epd[1], STDERR_FILENO);
close(epd[0]);
close(epd[1]);
+ close(spd[0]);
/* force dead.letter to go to cwd */
setenv("HOME", ".", 1);
/* exec mailx */
@@ -113,7 +114,7 @@ mailx_sigint(bool interactive)
close(spd[0]);
if (interactive) {
ATF_CHECK(WIFEXITED(status));
- ATF_CHECK_INTEQ(0, WEXITSTATUS(status));
+ ATF_CHECK_INTEQ(1, WEXITSTATUS(status));
ATF_CHECK_INTEQ(2, kc);
ATF_CHECK_STREQ("", obuf);
ATF_CHECK_MATCH("Interrupt -- one more to kill letter", ebuf);