From kurt@cantor.boolean.net  Tue Dec 29 15:29:26 1998
Received: from cantor.boolean.net (cantor.boolean.net [209.133.111.73])
          by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id PAA27609
          for <FreeBSD-gnats-submit@freebsd.org>; Tue, 29 Dec 1998 15:29:26 -0800 (PST)
          (envelope-from kurt@cantor.boolean.net)
Received: (from kurt@localhost)
	by cantor.boolean.net (8.9.1/8.9.1) id XAA71782;
	Tue, 29 Dec 1998 23:30:55 GMT
	(envelope-from kurt)
Message-Id: <199812292330.XAA71782@cantor.boolean.net>
Date: Tue, 29 Dec 1998 23:30:55 GMT
From: Kurt Zeilenga <kurt@boolean.net>
Reply-To: kurt@boolean.net
To: FreeBSD-gnats-submit@freebsd.org
Subject: pthread_exit doesn't exit
X-Send-Pr-Version: 3.2

>Number:         9237
>Category:       i386
>Synopsis:       pthread_exit doesn't exit
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Tue Dec 29 15:30:01 PST 1998
>Closed-Date:    Sat Aug 7 19:15:58 PDT 1999
>Last-Modified:  Sat Aug  7 19:16:51 PDT 1999
>Originator:     Kurt Zeilenga
>Release:        FreeBSD 3.0-CURRENT i386
>Organization:
OpenLDAP
>Environment:

FreeBSD cantor.boolean.net 3.0-CURRENT FreeBSD 3.0-CURRENT #0: Mon Dec  7 22:33:44 GMT 1998     kurt@cantor.boolean.net:/work/src/sys/compile/BOOLEAN  i386

cvsup'ed on 7 Dec, running elf kernel and executables
SMP

>Description:

	Calling pthread_exit() from only (main) thread 
	does not cause process to exit.

>How-To-Repeat:

#include <pthread.h>

int main(int argc, char** argv)
{
        pthread_exit( NULL );

        /* not reachable */
        return -2;
}

	cc -o threadtest threadtest.c -pthread
	./threadtest; echo $status

Process will not exit until interrupted/killed.
Top(1) shows process in 'select'.

>Fix:

Woraround: Keep track of number of active threads and
have last thread exit with exit() instead of phtread_exit().

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->feedback 
State-Changed-By: deischen 
State-Changed-When: Fri Aug 6 05:42:57 PDT 1999 
State-Changed-Why:  
This was fixed in both -current and -stable.  The supplied test program 
works.  I'll wait a week or so for feedback, then close the PR. 
State-Changed-From-To: feedback->closed 
State-Changed-By: deischen 
State-Changed-When: Sat Aug 7 19:15:58 PDT 1999 
State-Changed-Why:  
Received positive response from submitter. 
>Unformatted:
