freebsd-dev/bin
Dag-Erling Smørgrav 5807f35c54 dd: Fix SIGINT handling.
Currently, we handle SIGINT by calling summary() and _exit() directly from the signal handler, which we install after setup().  There are several issues with this:

* summary() is not signal safe;
* the parent is not informed about the signal;
* setup() can block on open(), and catching SIGINT at that stage will produce the correct exit status but will not print anything to stderr as POSIX demands.

Fix this by making SIGINT non-restartable, changing our signal handler to only set a flag, installing it before setup(), and checking the termination flag before and after every blocking operation, i.e. open(), read(), write().

Also add two test cases, one for catching SIGINT while opening the input and one for catching it while reading.  I couldn't think of an easy way to test catching SIGINT while writing (it's certainly feasible, but perhaps not from a shell script).

MFC after:	1 week
Sponsored by:	Klara, Inc.
Reviewed by:	cracauer, ngie, imp
Differential Revision:	https://reviews.freebsd.org/D39641
2023-05-05 12:42:32 +00:00
..
cat Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
chflags Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
chio Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
chmod Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
cp cp: Revert "If copy_file_range(2) fails with EXDEV, use fall-back." 2023-04-24 16:04:53 +00:00
csh Fix building host tools for host 2023-04-20 10:05:43 -07:00
date Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
dd dd: Fix SIGINT handling. 2023-05-05 12:42:32 +00:00
df Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
domainname Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
echo Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
ed Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
expr Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
freebsd-version freebsd-version(1): Add -j flag to support jails 2021-10-01 13:50:56 -05:00
getfacl Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
hostname Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
kenv Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
kill Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
ln Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
ls Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
mkdir Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
mv Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
nproc nproc: denote an incompatiblity with Linux 2023-02-15 20:43:46 +00:00
pax Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
pkill Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
ps ps: Add libxo to usage message 2023-04-25 17:23:07 +02:00
pwait Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
pwd Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
realpath Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
rm Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
rmail Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
rmdir Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
setfacl setfacl.1: correct reference to a trailing comma, should read "colon" 2023-04-29 12:22:52 +01:00
sh Fix building host tools for host 2023-04-20 10:05:43 -07:00
sleep Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
stty Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
sync Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
test Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
tests Merge ^/user/ngie/release-pkg-fix-tests to unbreak how test files are installed 2016-05-04 23:20:53 +00:00
timeout timeout: Move from /usr/bin to /bin 2023-02-02 18:34:35 +01:00
uuidgen Update/fix Makefile.depend for userland 2023-04-18 17:14:23 -07:00
Makefile Add nproc(1) 2023-02-08 19:47:33 +00:00
Makefile.inc build: provide a default WARNS for all in-tree builds 2020-09-18 17:17:46 +00:00