Date: Sun, 4 Feb 2001 15:12:25 -0800 (PST) From: John Polstra <jdp@polstra.com> To: hackers@freebsd.org Cc: mcgovern@spoon.beta.com Subject: Re: exit() does not do dlclose()? Message-ID: <200102042312.f14NCPk02811@vashon.polstra.com> In-Reply-To: <200102041654.f14Gsh808001@spoon.beta.com> References: <200102041654.f14Gsh808001@spoon.beta.com>
next in thread | previous in thread | raw e-mail | index | archive | help
In article <200102041654.f14Gsh808001@spoon.beta.com>,
Brian McGovern <mcgovern@spoon.beta.com> 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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200102042312.f14NCPk02811>
