From owner-svn-src-all@FreeBSD.ORG Tue Jan 18 21:18:32 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 48123106566C; Tue, 18 Jan 2011 21:18:32 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 36ED68FC08; Tue, 18 Jan 2011 21:18:32 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p0ILIWL7052346; Tue, 18 Jan 2011 21:18:32 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p0ILIWA4052343; Tue, 18 Jan 2011 21:18:32 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201101182118.p0ILIWA4052343@svn.freebsd.org> From: Jilles Tjoelker Date: Tue, 18 Jan 2011 21:18:32 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r217557 - in head: bin/sh tools/regression/bin/sh/execution X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 18 Jan 2011 21:18:32 -0000 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