Bug 50051

Summary: /bin/sh: child termination signals break valid shellscripts
Product: Base System Reporter: Peter Much <pmc>
Component: binAssignee: Tim Robbins <tjr>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.7-RELEASE   
Hardware: Any   
OS: Any   

Description Peter Much 2003-03-16 18:10:11 UTC
	
	An executable gets terminated by signal.
	/bin/sh will report the name of the signal not only
	to its stdout, but will also insert this text in the
	stdout of the next subshell.

Fix: 

Bernd Walter came up with the following suggestion. It
	seems to suit as a workaround:
		trap "wait" 20
How-To-Repeat: 
	1. Run /bin/sh
	2. Enter the command:
		sleep 30; test `ls | wc -l` -gt 0
	3. Kill the "sleep" process with the kill command from some
	   other tty.
	You will then see the "test" command failing with syntax
	error. When activating -x you will see the signal name
	being added to the output from "wc":
		+ sleep 30
		+ wc -l
		+ ls
		+ test 133 Terminated -gt 0
		Terminated
		test: 133: unexpected operator
Comment 1 Tim Robbins freebsd_committer freebsd_triage 2003-03-17 11:12:42 UTC
Responsible Changed
From-To: freebsd-bugs->tjr

I've tracked the problem down and will commit a fix to -current shortly.
Comment 2 Tim Robbins freebsd_committer freebsd_triage 2003-03-17 11:29:15 UTC
State Changed
From-To: open->patched

Fixed in -current; will be MFC'd after FreeBSD 4.8 has been released. 
Thanks for the report.
Comment 3 Tim Robbins freebsd_committer freebsd_triage 2003-04-04 09:16:32 UTC
State Changed
From-To: patched->closed

Fixed in -stable.