From owner-svn-src-stable@FreeBSD.ORG Sat Feb 5 20:25:18 2011 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 289C41065672; Sat, 5 Feb 2011 20:25:18 +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 F0AA08FC08; Sat, 5 Feb 2011 20:25:17 +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 p15KPH51039320; Sat, 5 Feb 2011 20:25:17 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p15KPHBS039317; Sat, 5 Feb 2011 20:25:17 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201102052025.p15KPHBS039317@svn.freebsd.org> From: Jilles Tjoelker Date: Sat, 5 Feb 2011 20:25:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r218337 - in stable/8: bin/sh tools/regression/bin/sh/execution X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 05 Feb 2011 20:25:18 -0000 Author: jilles Date: Sat Feb 5 20:25:17 2011 New Revision: 218337 URL: http://svn.freebsd.org/changeset/base/218337 Log: MFC r217557: 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 Added: stable/8/tools/regression/bin/sh/execution/killed1.0 - copied unchanged from r217557, head/tools/regression/bin/sh/execution/killed1.0 Modified: stable/8/bin/sh/jobs.c Directory Properties: stable/8/bin/sh/ (props changed) stable/8/tools/regression/bin/sh/ (props changed) Modified: stable/8/bin/sh/jobs.c ============================================================================== --- stable/8/bin/sh/jobs.c Sat Feb 5 20:23:12 2011 (r218336) +++ stable/8/bin/sh/jobs.c Sat Feb 5 20:25:17 2011 (r218337) @@ -1005,6 +1005,7 @@ dowait(int block, struct job *job) out1c('\n'); } else showjob(thisjob, pid, SHOWJOBS_DEFAULT); + flushout(out1); } } else { TRACE(("Not printing status, rootshell=%d, job=%p\n", rootshell, job)); Copied: stable/8/tools/regression/bin/sh/execution/killed1.0 (from r217557, head/tools/regression/bin/sh/execution/killed1.0) ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ stable/8/tools/regression/bin/sh/execution/killed1.0 Sat Feb 5 20:25:17 2011 (r218337, copy of r217557, head/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