summaryrefslogtreecommitdiff
path: root/static/unix-v10/man3/exit.3
blob: af44b48a66fd4cfbff2662a992d099522ff0b14d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
.TH EXIT 3
.CT 2 proc_man
.SH NAME
exit, onexit \(mi terminate process
.SH SYNOPSIS
.nf
.B void exit(status)
.B int status;
.PP
.B int onexit(fn)
.B int (*fn)();
.fi
.SH DESCRIPTION
.I Exit
is the conventional way to terminate a process.
Before calling
.I _exit
(see
.IR exit (2))
with
.I status
as an argument,
it calls in reverse order all the functions
recorded by
.IR onexit .
.PP
.I Exit
can never return.
.PP
.I Onexit
records
.I fn
as a function to be called by
.IR exit .
It returns zero if it failed,
nonzero otherwise.
Typical uses include cleanup routines for
.IR stdio (3)
and profiling; see
.IR monitor (3).
.PP
Calling
.I onexit
twice (or more) with the same function argument causes
.I exit
to invoke the function twice (or more).
.PP
The function
.I fn
should be declared as
.EX
       int fn()
.EE
.PP
The constant
.B NONEXIT
defined in
.B <libc.h>
determines how many functions can be recorded.
.SH "SEE ALSO"
.IR exit (2)