From 8534e72e04570d018bd86f47004261768cc2901d Mon Sep 17 00:00:00 2001 From: kn Date: Sun, 16 Oct 2022 12:34:13 +0000 Subject: [PATCH] Add new failing read/signal test ^C does not abort `read < /dev/zero', instead it read(2)s indefinitely, one null byte at a time; bash and ksh93 from ports abort as expected. Use the new timeout(1) $PROG trick to send ^C after 0.1s, but also rely on it's -k for the final SIGKILL to stop the busy-looping process. ./th's `time-limit: 1' prints "test timed out (limit of 1 seconds)" but leaves the process running. --- regress/bin/ksh/read.t | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/regress/bin/ksh/read.t b/regress/bin/ksh/read.t index 021d1e58870..83b93ad9cae 100644 --- a/regress/bin/ksh/read.t +++ b/regress/bin/ksh/read.t @@ -1,4 +1,4 @@ -# $OpenBSD: read.t,v 1.1 2013/12/02 20:39:44 millert Exp $ +# $OpenBSD: read.t,v 1.2 2022/10/16 12:34:13 kn Exp $ # # To test: @@ -56,3 +56,16 @@ expected-stdout: [abc] --- +name: signal-aborts-endless-read +description: + Check that an endless read can be interrupted. +# XXX ^C does nothing, needs uncatchable SIGKILL to stop +expected-fail: yes +stdin: + exec timeout --preserve-status -s INT -k 0.5s -- 0.1s $PROG -c ' + read < /dev/zero + ' +# 2/9 == INT/KILL +# XXX using signal expressions like 's == 2' only works with ksh +expected-exit: e == 128 + 2 +--- -- 2.20.1