]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" References consulted: | |
26 | .\" Linux libc source code | |
27 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
28 | .\" 386BSD man pages | |
29 | .\" Modified 1993-04-02, David Metcalfe | |
30 | .\" Modified 1993-07-25, Rik Faith (faith@cs.unc.edu) | |
4b8c67d9 | 31 | .TH ON_EXIT 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
fea681da | 32 | .SH NAME |
027df6e0 | 33 | on_exit \- register a function to be called at normal process termination |
fea681da MK |
34 | .SH SYNOPSIS |
35 | .nf | |
36 | .B #include <stdlib.h> | |
68e4db0a | 37 | .PP |
fea681da MK |
38 | .BI "int on_exit(void (*" function ")(int , void *), void *" arg ); |
39 | .fi | |
68e4db0a | 40 | .PP |
cc4615cc MK |
41 | .in -4n |
42 | Feature Test Macro Requirements for glibc (see | |
43 | .BR feature_test_macros (7)): | |
44 | .in | |
68e4db0a | 45 | .PP |
cc4615cc | 46 | .BR on_exit (): |
51c612fb MK |
47 | Since glibc 2.19: |
48 | _DEFAULT_SOURCE | |
49 | Glibc 2.19 and earlier: | |
50 | _BSD_SOURCE || _SVID_SOURCE | |
fea681da | 51 | .SH DESCRIPTION |
60a90ecd MK |
52 | The |
53 | .BR on_exit () | |
c6fa0841 MK |
54 | function registers the given |
55 | .I function | |
56 | to be | |
027df6e0 | 57 | called at normal process termination, whether via |
fea681da | 58 | .BR exit (3) |
c6fa0841 MK |
59 | or via return from the program's |
60 | .IR main (). | |
61 | The | |
62 | .I function | |
63 | is passed the status argument given to the last call to | |
fea681da | 64 | .BR exit (3) |
c6fa0841 MK |
65 | and the |
66 | .I arg | |
67 | argument from | |
60a90ecd | 68 | .BR on_exit (). |
847e0d88 | 69 | .PP |
6a275cde MK |
70 | The same function may be registered multiple times: |
71 | it is called once for each registration. | |
847e0d88 | 72 | .PP |
36a0cc25 MK |
73 | When a child process is created via |
74 | .BR fork (2), | |
75 | it inherits copies of its parent's registrations. | |
76 | Upon a successful call to one of the | |
77 | .BR exec (3) | |
78 | functions, all registrations are removed. | |
47297adb | 79 | .SH RETURN VALUE |
60a90ecd MK |
80 | The |
81 | .BR on_exit () | |
82 | function returns the value 0 if successful; otherwise | |
c7094399 | 83 | it returns a nonzero value. |
d388b47f ZL |
84 | .SH ATTRIBUTES |
85 | For an explanation of the terms used in this section, see | |
86 | .BR attributes (7). | |
87 | .TS | |
88 | allbox; | |
89 | lb lb lb | |
90 | l l l. | |
91 | Interface Attribute Value | |
92 | T{ | |
93 | .BR on_exit () | |
94 | T} Thread safety MT-Safe | |
95 | .TE | |
847e0d88 | 96 | .sp 1 |
47297adb | 97 | .SH CONFORMING TO |
a4b636a0 | 98 | This function comes from SunOS 4, but is also present in glibc. |
68e1685c | 99 | It no longer occurs in Solaris (SunOS 5). |
4ccc3a14 | 100 | Portable application should avoid this function, and use the standard |
fea681da MK |
101 | .BR atexit (3) |
102 | instead. | |
47297adb | 103 | .SH SEE ALSO |
c62b9eaa | 104 | .BR _exit (2), |
fea681da MK |
105 | .BR atexit (3), |
106 | .BR exit (3) |