Re: exit and _exit calls
From: Floyd L. Davidson (floyd_at_apaflo.com)
Date: 07/11/05
- Next message: Nils Weller: "Re: exit and _exit calls"
- Previous message: Ulrich Hobelmann: "Re: exit and _exit calls"
- In reply to: Rajan: "Re: exit and _exit calls"
- Next in thread: Nils Weller: "Re: exit and _exit calls"
- Reply: Nils Weller: "Re: exit and _exit calls"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Mon, 11 Jul 2005 07:16:31 -0800
"Rajan" <rstalekar@yahoo.com> wrote:
>Whatever you thought is not what the UNIX faq says, see the link below
>http://www.erlenstar.demon.co.uk/unix/faq_2.html
>
>It says :-
>The basic difference between exit() and _exit() is that the former
>performs clean-up related to user-mode constructs in the library, and
>calls user-supplied cleanup functions, whereas the latter performs only
>the kernel cleanup for the process.
Whatever you thought, the FAQ gives you additional background
information, answering specific questions, but does *not* define
the C language. You are reading far more into the FAQ than it
says. But worse you are ignoring documentation that does intend
to be the complete definition.
Read the man pages for exit(3) and _exit(2), and first take note
that (as befits what the FAQ says) exit() is in Section 3 and
_exit() is part of Section 2.
There are two other items to note. One is that the man pages
provide significantly more information, in distinctly pedantic
terminology, than does the FAQ. That is of course the
distintion between a man page and a FAQ. Second is that both
functions conform to the ANSI/ISO C Standard; and hence that
document should also be consulted if you want the definitive
statement on what those two functions must do. (See Sections
7.20.4.3 and 7.20.4.4.)
Specifically, one statement in the C Standard needs to be
emphasized, if you want to understand the statements in the FAQ:
2 The exit function causes normal program termination to
occur. If more than one call to the exit function is
executed by a program, the behavior is undefined.
7.20.4.3 ISO/IEC 9899:1999 (E)
That is why _exit(2) is necessary. If a program forks and
both resulting processes call exit(3), the result is undefined
behavior.
-- Floyd L. Davidson <http://web.newsguy.com/floyd_davidson> Ukpeagvik (Barrow, Alaska) floyd@barrow.com
- Next message: Nils Weller: "Re: exit and _exit calls"
- Previous message: Ulrich Hobelmann: "Re: exit and _exit calls"
- In reply to: Rajan: "Re: exit and _exit calls"
- Next in thread: Nils Weller: "Re: exit and _exit calls"
- Reply: Nils Weller: "Re: exit and _exit calls"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|