1explain_exit(3) Library Functions Manual explain_exit(3)
2
3
4
6 explain_exit - print an explanation of exit status before exiting
7
9 #include <libexplain/libexplain.h>
10 void explain_exit_on_exit(void);
11 void explain_exit_on_error(void);
12 void explain_exit_cancel(void);
13
15 The explain_exit_on_exit function may be used to have the calling pro‐
16 gram print an explanation of its exit status (the value passed to
17 exit(3) or the return value from main) immediately before it termi‐
18 nates.
19
20 The explain_exit_on_error function may be used to have the calling pro‐
21 gram print an explanation of its exit status immediately before it ter‐
22 minates, if that exit status is not EXIT_SUCCESS.
23
24 The explain_exit_cancel function may be used to cancel the effect of
25 the explain_exit_on_exit or explain_exit_on_error function.
26
27 These functions may be called multiple times, and in any order. The
28 last called has precedence. The explanation will never be printed more
29 than once.
30
31 Call Exit As Normal
32 In order to have the explanation printed, simply call exit(3) as nor‐
33 mal, or return from main as normal. Do not call any of these functions
34 in order to exit your program, they are called before you exit your
35 program.
36
37 Caveat
38 This functionality is only available on systems with the on_exit(3)
39 system call. Unfortunately, the atexit(3) system call is not suffi‐
40 ciently capable, as it does not pass the exit status to the registered
41 function.
42
44 exit(3) cause normal process termination
45
46 atexit(3)
47 register a function to be called at normal process termination
48
49 on_exit(3)
50 register a function to be called at normal process termination
51
53 libexplain version 1.4
54 Copyright (C) 2009 Peter Miller
55
57 Written by Peter Miller <pmiller@opensource.org.au>
58
59
60
61 explain_exit(3)