summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-05-03 15:28:31 +0000
committerjilles <jilles@FreeBSD.org>2013-05-03 15:28:31 +0000
commit3f27c6916965a63b42f0a8f1dc9c95cd75faa4fa (patch)
tree4595e56573a1621805ce3c9493340d4c3a9ce61c /tools
parentcc9f388839c014f29ebe7586e40ad11d1683c173 (diff)
downloadFreeBSD-src-3f27c6916965a63b42f0a8f1dc9c95cd75faa4fa.zip
FreeBSD-src-3f27c6916965a63b42f0a8f1dc9c95cd75faa4fa.tar.gz
sh: Improve error handling in read builtin:
* If read -t times out, return status as if interrupted by SIGALRM (formerly 1). * If a trapped signal interrupts read, return status 128+sig (formerly 1). * If [EINTR] occurs but there is no trap, retry the read (for example because of a SIGWINCH in interactive mode). * If a read error occurs, write an error message and return status 2. As before, a variable assignment error returns 2 and discards the remaining data read.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/bin/sh/builtins/read7.05
-rw-r--r--tools/regression/bin/sh/builtins/read8.013
2 files changed, 18 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/builtins/read7.0 b/tools/regression/bin/sh/builtins/read7.0
new file mode 100644
index 0000000..e78f887
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/read7.0
@@ -0,0 +1,5 @@
+# $FreeBSD$
+
+{ errmsg=`read x <&- 2>&1 >&3`; } 3>&1
+r=$?
+[ "$r" -ge 2 ] && [ "$r" -le 128 ] && [ -n "$errmsg" ]
diff --git a/tools/regression/bin/sh/builtins/read8.0 b/tools/regression/bin/sh/builtins/read8.0
new file mode 100644
index 0000000..40dd6fa
--- /dev/null
+++ b/tools/regression/bin/sh/builtins/read8.0
@@ -0,0 +1,13 @@
+# $FreeBSD$
+
+T=`mktemp -d ${TMPDIR:-/tmp}/sh-test.XXXXXX`
+trap 'rm -rf $T' 0
+cd $T || exit 3
+mkfifo fifo1
+trapped=
+trap trapped=1 QUIT
+{ kill -QUIT $$; sleep 1; exit 4; } >fifo1 &
+read dummy <fifo1
+r=$?
+kill $!
+[ "$r" -gt 128 ] && [ -n "$trapped" ]
OpenPOWER on IntegriCloud