段错误返回的进程是什么错误代码? [英] What error code does a process that segfaults return?

查看:25
本文介绍了段错误返回的进程是什么错误代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

段错误的进程返回什么错误代码?从我的实验来看,它似乎是139",但我想知道为什么会这样以及它有多标准.

What error code does a process that segfaults return? From my experiments, it seems to be "139", but I'd like to find why this is so and how standard it is.

推荐答案

相关的系统调用(给出终止进程的状态)是 waitpid(2).139 用于 WIFSIGNALEDWTERMSIG 等...在 Linux 上,实际位在内部文件 /usr/include/bits/waitstatus.h<sys/wait.h> header

The relevant syscall (giving the status of a terminated process) is waitpid(2). The 139 is for WIFSIGNALED and WTERMSIG etc... On Linux the actual bits are described in internal file /usr/include/bits/waitstatus.h which is included from <sys/wait.h> header

waitwaitpid 调用是 POSIX 中的标准 和宏名称也是如此(如 WTERMSIG 等...).这些宏的实际实现,以及实际的信号编号,因此 shell 给出的代码,都是特定于实现的.

The wait, waitpid call is standard in POSIX and so are the macro names (like WTERMSIG etc...). The actual implementation of these macros, and the actual signal numbers, hence the code given by the shell, are implementation specific.

signal(7) Linux 手册页给出了信号的数量.

The signal(7) Linux man page gives the number of the signals.

这篇关于段错误返回的进程是什么错误代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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