xref: /freebsd/share/man/man3/sysexits.3 (revision f126890ac5386406dadf7c4cfa9566cbb56537c5)
1.\"
2.\" Copyright (c) 1996 Joerg Wunsch
3.\"
4.\" All rights reserved.
5.\"
6.\" Redistribution and use in source and binary forms, with or without
7.\" modification, are permitted provided that the following conditions
8.\" are met:
9.\" 1. Redistributions of source code must retain the above copyright
10.\"    notice, this list of conditions and the following disclaimer.
11.\" 2. Redistributions in binary form must reproduce the above copyright
12.\"    notice, this list of conditions and the following disclaimer in the
13.\"    documentation and/or other materials provided with the distribution.
14.\"
15.\" THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY EXPRESS OR
16.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18.\" IN NO EVENT SHALL THE DEVELOPERS BE LIABLE FOR ANY DIRECT, INDIRECT,
19.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
20.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
21.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
22.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25.\"
26.\" "
27.Dd January 21, 2010
28.Dt SYSEXITS 3
29.Os
30.Sh NAME
31.Nm sysexits
32.Nd preferable exit codes for programs
33.Sh SYNOPSIS
34.In sysexits.h
35.Sh DESCRIPTION
36According to
37.Xr style 9 ,
38it is not a good practice to call
39.Xr exit 3
40with arbitrary values to indicate a failure condition when ending
41a program.
42Instead, the pre-defined exit codes from
43.Nm
44should be used, so the caller of the process can get a rough
45estimation about the failure class without looking up the source code.
46.Pp
47The successful exit is always indicated by a status of 0, or
48.Sy EX_OK .
49Error numbers begin at
50.Sy EX__BASE
51to reduce the possibility of clashing with other exit statuses that
52random programs may already return.
53The meaning of the codes is
54approximately as follows:
55.Bl -tag -width "EX_UNAVAILABLEXX(XX)"
56.It Sy EX_USAGE Pq 64
57The command was used incorrectly, e.g., with the wrong number of
58arguments, a bad flag, a bad syntax in a parameter, or whatever.
59.It Sy EX_DATAERR Pq 65
60The input data was incorrect in some way.
61This should only be used
62for user's data and not system files.
63.It Sy EX_NOINPUT Pq 66
64An input file (not a system file) did not exist or was not readable.
65This could also include errors like
66.Dq \&No message
67to a mailer (if it cared to catch it).
68.It Sy EX_NOUSER Pq 67
69The user specified did not exist.
70This might be used for mail
71addresses or remote logins.
72.It Sy EX_NOHOST Pq 68
73The host specified did not exist.
74This is used in mail addresses or
75network requests.
76.It Sy EX_UNAVAILABLE Pq 69
77A service is unavailable.
78This can occur if a support program or file
79does not exist.
80This can also be used as a catchall message when
81something you wanted to do does not work, but you do not know why.
82.It Sy EX_SOFTWARE Pq 70
83An internal software error has been detected.
84This should be limited
85to non-operating system related errors as possible.
86.It Sy EX_OSERR Pq 71
87An operating system error has been detected.
88This is intended to be
89used for such things as
90.Dq cannot fork ,
91.Dq cannot create pipe ,
92or the like.
93It includes things like getuid returning a user that
94does not exist in the passwd file.
95.It Sy EX_OSFILE Pq 72
96Some system file (e.g.,
97.Pa /etc/passwd ,
98.Pa /var/run/utx.active ,
99etc.) does not exist, cannot be opened, or has some sort of error
100(e.g., syntax error).
101.It Sy EX_CANTCREAT Pq 73
102A (user specified) output file cannot be created.
103.It Sy EX_IOERR Pq 74
104An error occurred while doing I/O on some file.
105.It Sy EX_TEMPFAIL Pq 75
106Temporary failure, indicating something that is not really an error.
107In sendmail, this means that a mailer (e.g.) could not create a
108connection, and the request should be reattempted later.
109.It Sy EX_PROTOCOL Pq 76
110The remote system returned something that was
111.Dq not possible
112during a protocol exchange.
113.It Sy EX_NOPERM Pq 77
114You did not have sufficient permission to perform the operation.
115This
116is not intended for file system problems, which should use
117.Sy EX_NOINPUT
118or
119.Sy EX_CANTCREAT ,
120but rather for higher level permissions.
121.It Sy EX_CONFIG Pq 78
122Something was found in an unconfigured or misconfigured state.
123.El
124.Pp
125The numerical values corresponding to the symbolical ones are given in
126parenthesis for easy reference.
127.Sh SEE ALSO
128.Xr err 3 ,
129.Xr exit 3 ,
130.Xr style 9
131.Sh HISTORY
132The
133.Nm
134file appeared somewhere after
135.Bx 4.3 .
136.Sh AUTHORS
137This manual page was written by
138.An J\(:org Wunsch
139after the comments in
140.In sysexits.h .
141.Sh BUGS
142The choice of an appropriate exit value is often ambiguous.
143