From eugen@grosbein.pp.ru  Sat Oct 18 03:25:21 2003
Return-Path: <eugen@grosbein.pp.ru>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 0898616A4B3
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 18 Oct 2003 03:25:20 -0700 (PDT)
Received: from grosbein.pp.ru (D00015.dialonly.kemerovo.su [213.184.66.105])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7C3B943F93
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 18 Oct 2003 03:25:16 -0700 (PDT)
	(envelope-from eugen@grosbein.pp.ru)
Received: from grosbein.pp.ru (smmsp@localhost [127.0.0.1])
	by grosbein.pp.ru (8.12.9p2/8.12.9) with ESMTP id h9IAP0JA030629
	for <FreeBSD-gnats-submit@freebsd.org>; Sat, 18 Oct 2003 18:25:00 +0800 (KRAST)
	(envelope-from eugen@grosbein.pp.ru)
Received: (from eugen@localhost)
	by grosbein.pp.ru (8.12.9p2/8.12.9/Submit) id h9IAHlFl030453;
	Sat, 18 Oct 2003 18:17:47 +0800 (KRAST)
	(envelope-from eugen)
Message-Id: <200310181017.h9IAHlFl030453@grosbein.pp.ru>
Date: Sat, 18 Oct 2003 18:17:47 +0800 (KRAST)
From: Eugene Grosbein <eugen@kuzbass.ru>
Reply-To: Eugene Grosbein <eugen@kuzbass.ru>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: /bin/sh sometimes run endless loop inside dowait()
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         58195
>Category:       bin
>Synopsis:       /bin/sh sometimes run endless loop inside dowait()
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Oct 18 03:30:17 PDT 2003
>Closed-Date:    Thu May 06 11:23:22 PDT 2004
>Last-Modified:  Thu May 06 11:23:22 PDT 2004
>Originator:     Eugene Grosbein
>Release:        FreeBSD 4.9-RC i386
>Organization:
Svyaz Service JSC
>Environment:
System: FreeBSD grosbein.pp.ru 4.9-RC FreeBSD 4.9-RC #24: Mon Oct 6 22:19:39 KRAST 2003 eu@grosbein.pp.ru:/usr/local/obj/usr/local/src/sys/DADV i386

>Description:
	
	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.

>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.

>Fix:

	Unknown for me.
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: maxim 
State-Changed-When: Thu May 6 11:22:05 PDT 2004 
State-Changed-Why:  
Submitter said the PR is duplicate of bin/66242 which has a patch. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=58195 
>Unformatted:
