> For the complete documentation index, see [llms.txt](https://book.bsdcn.org/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://book.bsdcn.org/man/misc/sysexits.3.md).

# sysexits.3

`sysexits` — 系统程序的旧式退出状态码

## 名称

`sysexits`

## 概要

```c
#include <sysexits.h>
```

## 描述

某些命令尝试通过使用这些预定义的退出代码来描述失败条件的性质。此接口已被弃用，仅为兼容性而保留。不鼓励使用。

## 错误

成功的退出始终由状态 0（即 **EX\_OK**）指示。错误编号从 **EX\_\_BASE** 开始，以减少与随机程序可能已经返回的其他退出状态冲突的可能性。各代码的含义大致如下：

**`EX_USAGE`** (64) 命令使用不正确，例如参数数量错误、标志错误、参数语法错误等。

**`EX_DATAERR`** (65) 输入数据在某方面不正确。这仅应用于用户数据而非系统文件。

**`EX_NOINPUT`** (66) 输入文件（非系统文件）不存在或不可读。这也可能包括对邮件程序（如果它愿意捕获）的"No message"等错误。

**`EX_NOUSER`** (67) 指定的用户不存在。这可能用于邮件地址或远程登录。

**`EX_NOHOST`** (68) 指定的主机不存在。用于邮件地址或网络请求。

**`EX_UNAVAILABLE`** (69) 服务不可用。如果支持程序或文件不存在，可能会发生此情况。当想执行某操作但不知道为何不工作时，这也可以用作兜底消息。

**`EX_SOFTWARE`** (70) 检测到内部软件错误。应尽可能限于非操作系统相关的错误。

**`EX_OSERR`** (71) 检测到操作系统错误。用于诸如"cannot fork"、"cannot create pipe"之类的情况。它包括诸如 getuid 返回 passwd 文件中不存在的用户等情况。

**`EX_OSFILE`** (72) 某些系统文件（例如 **`/etc/passwd`**、**`/var/run/utx.active`** 等）不存在、无法打开或有某种错误（例如语法错误）。

**`EX_CANTCREAT`** (73) 无法创建（用户指定的）输出文件。

**`EX_IOERR`** (74) 在某个文件上执行 I/O 时发生错误。

**`EX_TEMPFAIL`** (75) 临时失败，表示并非真正的错误。在 sendmail 中，这意味着邮件程序（例如）无法创建连接，应稍后重试请求。

**`EX_PROTOCOL`** (76) 远程系统在协议交换期间返回了"不可能"的内容。

**`EX_NOPERM`** (77) 没有足够的权限执行操作。这并非用于文件系统问题（应使用 **EX\_NOINPUT** 或 **EX\_CANTCREAT**），而是用于更高级别的权限。

**`EX_CONFIG`** (78) 发现某物处于未配置或配置错误的状态。

括号中给出了与符号值对应的数值，便于参考。

## 参见

err(3), exit(3), [style(9)](https://github.com/FreeBSD-Ask/freebsd-man-sc/blob/main/man9/style.9.md)

## 历史

`sysexits` 文件首次出现于 4BSD。

## 作者

本手册页由 Jörg Wunsch 编写。

## 缺陷

**此**接口不可移植。

**选择**适当的退出值通常存在歧义。


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://book.bsdcn.org/man/misc/sysexits.3.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
