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():
17           Since glibc 2.19:
18               _DEFAULT_SOURCE
19           Glibc 2.19 and earlier:
20               _BSD_SOURCE || _SVID_SOURCE
21

DESCRIPTION

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

RETURN VALUE

36       The on_exit() function returns the value 0 if successful; otherwise  it
37       returns a nonzero value.
38

ATTRIBUTES

40       For   an   explanation   of   the  terms  used  in  this  section,  see
41       attributes(7).
42
43       ┌──────────┬───────────────┬─────────┐
44Interface Attribute     Value   
45       ├──────────┼───────────────┼─────────┤
46on_exit() │ Thread safety │ MT-Safe │
47       └──────────┴───────────────┴─────────┘
48

CONFORMING TO

50       This function comes from SunOS 4, but is also present in glibc.  It  no
51       longer  occurs in Solaris (SunOS 5).  Portable application should avoid
52       this function, and use the standard atexit(3) instead.
53

SEE ALSO

55       _exit(2), atexit(3), exit(3)
56

COLOPHON

58       This page is part of release 4.16 of the Linux  man-pages  project.   A
59       description  of  the project, information about reporting bugs, and the
60       latest    version    of    this    page,    can     be     found     at
61       https://www.kernel.org/doc/man-pages/.
62
63
64
65GNU                               2017-09-15                        ON_EXIT(3)
Impressum