Date: Fri, 5 May 2023 21:21:36 +0300 From: Konstantin Belousov <kostikbel@gmail.com> To: Dag-Erling =?utf-8?B?U23DuHJncmF2?= <des@freebsd.org> Cc: src-committers@freebsd.org, dev-commits-src-all@freebsd.org, dev-commits-src-main@freebsd.org Subject: Re: git: 5807f35c541c - main - dd: Fix SIGINT handling. Message-ID: <ZFVJMIKu4v4OnPZL@kib.kiev.ua> In-Reply-To: <202305051245.345CjNLE048275@gitrepo.freebsd.org>
index | next in thread | previous in thread | raw e-mail
On Fri, May 05, 2023 at 12:45:23PM +0000, Dag-Erling Smørgrav wrote: > The branch main has been updated by des: > > URL: https://cgit.FreeBSD.org/src/commit/?id=5807f35c541c26bbd91a3ae12506cd8dd8f20688 > > commit 5807f35c541c26bbd91a3ae12506cd8dd8f20688 > Author: Dag-Erling Smørgrav <des@FreeBSD.org> > AuthorDate: 2023-05-05 11:17:44 +0000 > Commit: Dag-Erling Smørgrav <des@FreeBSD.org> > CommitDate: 2023-05-05 12:42:32 +0000 > > 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). > This does not fix SIGINT handler, it only (significantly) reduces the window where the issue could occur. See my latest comment on the review.home | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?ZFVJMIKu4v4OnPZL>
