Bug 58195

Summary: /bin/sh sometimes run endless loop inside dowait()
Product: Base System Reporter: Eugene Grosbein <ports>
Component: binAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: Unspecified   
Hardware: Any   
OS: Any   

Description Eugene Grosbein 2003-10-18 11:30:17 UTC
	
	A function waitforjob() in src/bin/sh/jobs.c contains following code:

        while (jp->state == 0)
                if (dowait(1, jp) == -1)
                        dotrap();

	This loop may be endless.

Fix: 

Unknown for me.
How-To-Repeat: 
	This is 100% repeatable for me using the following test.sh:

#!/bin/sh

subr() {
  { sleep 3600 & sleep 1; kill $!; } &
}

set -T
trap 'subr &' USR1
while :
do
 sleep 5
done

	Run it:
	
	sh -c './test.sh & for i in `jot 10 1`; do kill -USR1 $!; done; top'

	Wait 5 seconds and see how /bin/sh eats CPU in this endless loop.
Comment 1 Maxim Konovalov freebsd_committer freebsd_triage 2004-05-06 19:22:05 UTC
State Changed
From-To: open->closed

Submitter said the PR is duplicate of bin/66242 which has a patch.