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