01-04-08 06:38 AM
On Thu, 03 Jan 2008 16:27:43 +0100, Spoon <root@localhost> wrote:
>Casper H.S. Dik wrote:
>
> I suppose the above stands for Solaris?
>
> POSIX states:
>
> "The _Exit() and _exit() functions shall not call functions registered
> with atexit() nor any registered signal handlers. Whether open streams
> are flushed or closed, or temporary files are removed is
> implementation-defined."
>
> So what happens in Linux? in FreeBSD?
The source of all the systems you mentioned is freely available online,
so you can read it and find out easily. If you are into this sort of
thing, then it may be interesting to skim through the Solaris sources
at the OpenSolaris web site:
http://cvs.opensolaris.org/
The search tool at the cvs.opensolaris.org site is _very_ fast and one
of the best ones I've used. Give it a go, if you like learning about
the internals of Solaris.
The same holds true for FreeBSD. The source of the exit(3) library
function is amazingly short in FreeBSD, and you can find its latest
version at:
http://cvsweb.freebsd.org/src/libc/libc/stdlib/exit.c
The normal exit(3) library function is mapped by the runtime linker to
the libc.so implementation of exit(). The libc.so exit() function then
does the following:
* It flushes any open file descriptors
* It updates internal FILE object attributes
* It calls any registered atexit() handlers
* It hands control over to the kernel, for _exit()
The _exit() symbol is a thin libc.so wrapper around the kernel function
sys_exit() which does the rest.
The files of the FreeBSD source tree which might be interesting, if you
are interested in even _more_ details include (but are probably not
limited only to) the following:
http://cvsweb.freebsd.org/src/libc/libc/stdlib/exit.c
http://cvsweb.freebsd.org/src/libc/libc/stdio/findfp.c
http://cvsweb.freebsd.org/src/libc/libc/stdio/fflush.c
http://cvsweb.freebsd.org/src/sys/kern/kern_exit.c
HTH,
Giorgos
[ Post a follow-up to this message ]
|