From nobody@FreeBSD.org  Fri Sep  6 06:06:27 2002
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id E20B737B400
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  6 Sep 2002 06:06:26 -0700 (PDT)
Received: from www.freebsd.org (www.FreeBSD.org [216.136.204.117])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 9708043E72
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  6 Sep 2002 06:06:26 -0700 (PDT)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.12.4/8.12.4) with ESMTP id g86D6POT060967
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 6 Sep 2002 06:06:25 -0700 (PDT)
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.12.4/8.12.4/Submit) id g86D6Pmw060965;
	Fri, 6 Sep 2002 06:06:25 -0700 (PDT)
Message-Id: <200209061306.g86D6Pmw060965@www.freebsd.org>
Date: Fri, 6 Sep 2002 06:06:25 -0700 (PDT)
From: Pierre-Etienne Moreau <Pierre-Etienne.Moreau@loria.fr>
To: freebsd-gnats-submit@FreeBSD.org
Subject: atexit+exit result in infinite recursive calls
X-Send-Pr-Version: www-1.0

>Number:         42477
>Category:       i386
>Synopsis:       atexit+exit result in infinite recursive calls
>Confidential:   no
>Severity:       serious
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Sep 06 06:10:01 PDT 2002
>Closed-Date:    Fri Sep 06 12:07:30 PDT 2002
>Last-Modified:  Fri Sep 06 12:07:30 PDT 2002
>Originator:     Pierre-Etienne Moreau
>Release:        4.6-STABLE
>Organization:
Loria - INRIA
>Environment:
FreeBSD escher.loria.fr 4.6-STABLE FreeBSD 4.6-STABLE #0: Mon Aug 26 11:30:41 CEST 2002     pem@escher.loria.fr:/usr/obj/usr/src/sys/ESCHER  i386

>Description:
What is the behavior of exit() when an exit() function is called by a function recorded by atexit() ?

On Linux and solaris, exit() is called only once
On FreeBSD, an infinite loop occurs

>How-To-Repeat:
#include <stdlib.h>
#include <stdio.h>
void f() { printf("f\n"); exit(1); }
main()   { atexit(f); exit(0); }
 
>Fix:
      
>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: wollman 
State-Changed-When: Fri Sep 6 12:04:39 PDT 2002 
State-Changed-Why:  
I believe that the behavior noted is within the bounds of the relevant 
standards.  Functions registerd with atexit() must call _exit() if they 
need to prevent further normal exit() processing.  (C99 added the _Exit() 
function for this reason among others, but we do not yet implement it, 
and even if we did, it would just call _exit().) 

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