mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-14 10:09:48 +00:00
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
This commit is contained in:
parent
5bc0787f29
commit
0d5ccb45d8
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=217557
@ -1062,6 +1062,7 @@ dowait(int block, struct job *job)
|
||||
if (coredump)
|
||||
out1str(" (core dumped)");
|
||||
out1c('\n');
|
||||
flushout(out1);
|
||||
}
|
||||
} else {
|
||||
TRACE(("Not printing status, rootshell=%d, job=%p\n", rootshell, job));
|
||||
|
8
tools/regression/bin/sh/execution/killed1.0
Normal file
8
tools/regression/bin/sh/execution/killed1.0
Normal file
@ -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
|
Loading…
Reference in New Issue
Block a user