1ON_EXIT(3)                 Linux Programmer's Manual                ON_EXIT(3)
2
3
4

NAME

6       on_exit  -  register a function to be called at normal process termina‐
7       tion
8

SYNOPSIS

10       #include <stdlib.h>
11
12       int on_exit(void (*function)(int , void *), void *arg);
13
14   Feature Test Macro Requirements for glibc (see feature_test_macros(7)):
15
16       on_exit(): _BSD_SOURCE || _SVID_SOURCE
17

DESCRIPTION

19       The on_exit() function registers the given function  to  be  called  at
20       normal  process termination, whether via exit(3) or via return from the
21       program's main().  The function is passed the status argument given  to
22       the last call to exit(3) and the arg argument from on_exit().
23
24       The  same  function may be registered multiple times: it is called once
25       for each registration.
26
27       When a child process is created via fork(2), it inherits copies of  its
28       parent's  registrations.   Upon a successful call to one of the exec(3)
29       functions, all registrations are removed.
30

RETURN VALUE

32       The on_exit() function returns the value 0 if successful; otherwise  it
33       returns a nonzero value.
34

CONFORMING TO

36       This  function  comes from SunOS 4, but is also present in libc4, libc5
37       and glibc.  It no longer occurs in Solaris (SunOS 5).  Avoid this func‐
38       tion, and use the standard atexit(3) instead.
39

SEE ALSO

41       _exit(2), atexit(3), exit(3)
42

COLOPHON

44       This  page  is  part of release 3.25 of the Linux man-pages project.  A
45       description of the project, and information about reporting  bugs,  can
46       be found at http://www.kernel.org/doc/man-pages/.
47
48
49
50GNU                               2008-12-05                        ON_EXIT(3)
Impressum