From owner-freebsd-hackers Sun Feb 4 15:12:50 2001 Delivered-To: freebsd-hackers@freebsd.org Received: from wall.polstra.com (rtrwan160.accessone.com [206.213.115.74]) by hub.freebsd.org (Postfix) with ESMTP id 6528437B4EC for ; Sun, 4 Feb 2001 15:12:32 -0800 (PST) Received: from vashon.polstra.com (vashon.polstra.com [206.213.73.13]) by wall.polstra.com (8.11.1/8.11.1) with ESMTP id f14NCT292154; Sun, 4 Feb 2001 15:12:29 -0800 (PST) (envelope-from jdp@wall.polstra.com) Received: (from jdp@localhost) by vashon.polstra.com (8.11.1/8.11.0) id f14NCPk02811; Sun, 4 Feb 2001 15:12:25 -0800 (PST) (envelope-from jdp) Date: Sun, 4 Feb 2001 15:12:25 -0800 (PST) Message-Id: <200102042312.f14NCPk02811@vashon.polstra.com> To: hackers@freebsd.org From: John Polstra Reply-To: hackers@freebsd.org Cc: mcgovern@spoon.beta.com Subject: Re: exit() does not do dlclose()? In-Reply-To: <200102041654.f14Gsh808001@spoon.beta.com> References: <200102041654.f14Gsh808001@spoon.beta.com> Organization: Polstra & Co., Seattle, WA Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In article <200102041654.f14Gsh808001@spoon.beta.com>, Brian McGovern wrote: > I'm playing with an application that uses dlopen() to load some libraries. I > use the _init function to set the libraries up. I've also set up the _fini > functions to shut things down. > > I see, in the man page, that dlclose() will unload the libraries and call > _fini. > > My question is whether or not exit() does the same thing? It currently does > not appear to, although that would seem rather odd to me, given the other > types of cleanup it does. It should clean them up including calling their _fini functions. From src/libexec/rtld-elf/rtld.c: /* * Cleanup procedure. It will be called (by the atexit mechanism) just * before the process exits. */ static void rtld_exit(void) { Obj_Entry *obj; dbg("rtld_exit()"); wlock_acquire(); /* Clear all the reference counts so the fini functions will be called. */ for (obj = obj_list; obj != NULL; obj = obj->next) obj->refcount = 0; wlock_release(); objlist_call_fini(&list_fini); /* No need to remove the items from the list, since we are exiting. */ } If you can come up with a reasonably self-contained test case that shows a bug in this, I'll be happy to take a look at it. John -- John Polstra jdp@polstra.com John D. Polstra & Co., Inc. Seattle, Washington USA "Disappointment is a good sign of basic intelligence." -- Chögyam Trungpa To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message