mail: Don't trap signals we shouldn't.
When in interactive mode, trap SIGINT, SIGHUP, and tty-related signals.
Otherwise, leave signals untouched as required by POSIX.
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: kevans
Differential Revision: https://reviews.freebsd.org/D50011
(cherry picked from commit 59597032c948586257f123f57bbcfbad02a2cd1b)
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
(cherry picked from commit 09bc6a5d5b3333bc91e5f9fdf1e7bb282c4aea5a)
mail: Further refine the SIGINT test.
- Wait at least 1-2 s before sending the second SIGINT.
- If the child is still running after 15 s, send a SIGKILL.
- Improve the exit status checks.
Fixes: 59597032c948
MFC after: 1 week
Sponsored by: Klara, Inc.
Reviewed by: markj
Differential Revision: https://reviews.freebsd.org/D50092
(cherry picked from commit 42fd47ef81138ae53ba77add5a400f67af8e6263)