Date: Tue, 18 Jan 2011 21:18:32 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r217557 - in head: bin/sh tools/regression/bin/sh/execution Message-ID: <201101182118.p0ILIWA4052343@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jilles Date: Tue Jan 18 21:18:31 2011 New Revision: 217557 URL: http://svn.freebsd.org/changeset/base/217557 Log: 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 Added: head/tools/regression/bin/sh/execution/killed1.0 (contents, props changed) Modified: head/bin/sh/jobs.c Modified: head/bin/sh/jobs.c ============================================================================== --- head/bin/sh/jobs.c Tue Jan 18 21:14:23 2011 (r217556) +++ head/bin/sh/jobs.c Tue Jan 18 21:18:31 2011 (r217557) @@ -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)); Added: head/tools/regression/bin/sh/execution/killed1.0 ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/tools/regression/bin/sh/execution/killed1.0 Tue Jan 18 21:18:31 2011 (r217557) @@ -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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101182118.p0ILIWA4052343>