2 .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
4 .\" SPDX-License-Identifier: Linux-man-pages-copyleft
6 .\" References consulted:
7 .\" Linux libc source code
8 .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
10 .\" Modified 1993-04-02, David Metcalfe
11 .\" Modified 1993-07-25, Rik Faith (faith@cs.unc.edu)
12 .TH on_exit 3 (date) "Linux man-pages (unreleased)"
14 on_exit \- register a function to be called at normal process termination
17 .RI ( libc ", " \-lc )
20 .B #include <stdlib.h>
22 .BI "int on_exit(void (*" function ")(int, void *), void *" arg );
26 Feature Test Macro Requirements for glibc (see
27 .BR feature_test_macros (7)):
34 glibc 2.19 and earlier:
35 _BSD_SOURCE || _SVID_SOURCE
40 function registers the given
43 called at normal process termination, whether via
45 or via return from the program's
49 is passed the status argument given to the last call to
56 The same function may be registered multiple times:
57 it is called once for each registration.
59 When a child process is created via
61 it inherits copies of its parent's registrations.
62 Upon a successful call to one of the
64 functions, all registrations are removed.
68 function returns the value 0 if successful; otherwise
69 it returns a nonzero value.
71 For an explanation of the terms used in this section, see
77 Interface Attribute Value
82 T} Thread safety MT-Safe
88 Removed in Solaris (SunOS 5).
97 variables may already have gone out of scope.
100 should not be a pointer to a stack variable;
101 it may however be a pointer to a heap variable or a global variable.