svn commit: r218337 - in stable/8: bin/sh tools/regression/bin/sh/execution

Jilles Tjoelker jilles at FreeBSD.org
Sat Feb 5 20:25:18 UTC 2011


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


More information about the svn-src-all mailing list