C中退出代码11的含义? [英] Meaning of Exit Code 11 in C?

查看:60
本文介绍了C中退出代码11的含义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

C 中退出代码 11 的一般含义是什么?我环顾四周,找不到明确的答案,所以我想我会在这里问.当我尝试将元素添加到向量时,它就会出现.

What's the general meaning of an exit code 11 in C? I've looked around and can not find a definitive answer so I thought I would ask here. It comes when i try to add an element to a vector.

推荐答案

您没有找到明确的答案,因为没有.由程序的作者决定他们希望使用哪些退出代码.标准 C 只说 exit(0)exit(EXIT_SUCCESS) 表示程序成功,而 exit(EXIT_FAILURE) 表示某种错误.(从 main 返回一个值等同于使用该值调用 exit.)大多数常见的操作系统,包括 Windows、Linux、OSX 等.使用 0 表示成功,值来自1 到 255 表示错误;仍然在错误代码之间进行选择取决于应用程序编写者,值 11 没有什么特别的.

You didn't find a definitive answer because there isn't one. It's up to the author of the program to decide what exit codes they wish to use. Standard C only says that exit(0) or exit(EXIT_SUCCESS) indicate that the program is successful, and that exit(EXIT_FAILURE) indicates an error of some kind. (Returning a value from main is equivalent to calling exit with that value.) Most common operating systems including Windows, Linux, OSX, etc. use 0 for success and values from 1 to 255 to indicate errors; still choosing between error codes is up to the application writer, the value 11 isn't anything special.

在 Linux 和大多数其他 Unix 变体下,信号 数字 11 表示 分段错误,如 Kerrek SB 评论.当程序进行某种无效的内存访问时,就会发生分段错误,因此它是越界访问数组、指针算术错误、尝试访问空指针或其他与指针相关的错误的合理结果.信号 11 与退出代码 11 不同:当程序因信号而死时,它被标记为已被信号杀死,而不是正常退出.Unix shell 通过报告退出代码来报告信号,退出代码是信号编号加 128,因此 139 表示分段错误.

Under Linux and most other Unix variants, the signal number 11 indicates a segmentation fault, as remarked by Kerrek SB. A segmentation fault happens when a program makes some kind of invalid memory access, so it's a plausible consequence of accessing an array out of bounds, or an error in pointer arithmetic, or trying to access a null pointer, or other pointer-related errors. Signal 11 is not the same thing as exit code 11: when a program dies due to a signal, it's marked as having been killed by a signal, rather than having exited normally. Unix shells report signals by reporting an exit code which is the signal number plus 128, so 139 for a segmentation fault.

这篇关于C中退出代码11的含义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆