Date: Sat, 5 Feb 2011 20:25:17 +0000 (UTC) From: Jilles Tjoelker <jilles@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r218337 - in stable/8: bin/sh tools/regression/bin/sh/execution Message-ID: <201102052025.p15KPHBS039317@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201102052025.p15KPHBS039317>