Bug 6982 - atexit() hooks are not called on exec()
Summary: atexit() hooks are not called on exec()
Status: RESOLVED INVALID
Alias: None
Product: glibc
Classification: Unclassified
Component: libc (show other bugs)
Version: 2.8
: P2 normal
Target Milestone: ---
Assignee: Ulrich Drepper
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2008-10-24 18:46 UTC by Andrew Zabolotny
Modified: 2014-07-02 06:04 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Andrew Zabolotny 2008-10-24 18:46:15 UTC
"man 3 exit" says, amongst other:

...
The  exit()  function  causes  normal process termination and the value of
status & 0377 is returned to the parent (see wait(2)).

All functions registered with atexit(3) and on_exit(3) are called, in  the
reverse  order  of  their  registration.
...

However, the atexit() hooks are never called if you invoke any of the exec*()
functions.

Steps to Reproduce:
1. Copy the example from 'man 3 atexit' to test.c
2. Modify it so that instead of "exit(EXIT_SUCCESS)" at the end we have, for
example:

execl ("/bin/ls", "ls");

3. Compile and run the example

Actual results:

$ ./a.out 
ATEXIT_MAX = 2147483647
a.out  test.c

Expected results:

$ ./a.out 
ATEXIT_MAX = 2147483647
That was all, folks
a.out  test.c

I think it is a serious bug as it does not allow applications that rely on it
to cleanup things that won't automatically cleanup during a normal process
destruction.
Comment 1 Ulrich Drepper 2008-10-24 18:51:12 UTC
They are not meant to be called at exec time.  Just read the standards.
Comment 2 Andrew Zabolotny 2008-10-24 18:53:31 UTC
(In reply to comment #1)
> They are not meant to be called at exec time.  Just read the standards.
So it's a bug in the man page?