diff options
author | jilles <jilles@FreeBSD.org> | 2011-01-18 21:18:31 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2011-01-18 21:18:31 +0000 |
commit | 460d7b088e1fcacc12a5985f400dd2b4e41a65fd (patch) | |
tree | e3185c2bc84fb3c92c11b744d194a7cdac94a3f2 /tools | |
parent | a21f29df61a761f6438742ccfd43413f251be25c (diff) | |
download | FreeBSD-src-460d7b088e1fcacc12a5985f400dd2b4e41a65fd.zip FreeBSD-src-460d7b088e1fcacc12a5985f400dd2b4e41a65fd.tar.gz |
sh: Fix signal messages being sent to the wrong file sometimes.
When a foreground job exits on a signal, a message is printed to stdout
about this. The buffer was not flushed after this which could result in the
message being written to the wrong file if the next command was a builtin
and had stdout redirected.
Example:
sh -c 'kill -9 $$'; : > foo; echo FOO:; cat foo
Reported by: gcooper
MFC after: 1 week
Diffstat (limited to 'tools')
-rw-r--r-- | tools/regression/bin/sh/execution/killed1.0 | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/tools/regression/bin/sh/execution/killed1.0 b/tools/regression/bin/sh/execution/killed1.0 new file mode 100644 index 0000000..41d3e05 --- /dev/null +++ b/tools/regression/bin/sh/execution/killed1.0 @@ -0,0 +1,8 @@ +# $FreeBSD$ +# Sometimes the "Killed" message is not flushed soon enough and it +# is redirected along with the output of a builtin. +# Do not change the semicolon to a newline as it would hide the bug. + +exec 3>&1 +exec >/dev/null 2>&1 +${SH} -c 'kill -9 $$'; : >&3 2>&3 |