什么WEXITSTATUS(状态)的回报? [英] What does WEXITSTATUS(status) return?

查看:1846
本文介绍了什么WEXITSTATUS(状态)的回报?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想了解如何 WEXITSTATUS(状态)的作品。我所遇到的一件code哪里的返回值 WEXITSTATUS(状态)被添加到一个变量。

I am trying to understand how WEXITSTATUS(status) works. I have come across a piece of code where the return value of WEXITSTATUS(status) is being added to a variable.

下面是片段:

waitpid(-1, &status, 0);
counter += WEXITSTATUS(status);

如何才能返回值 WEXITSTATUS 计算?

推荐答案

WEXITSTATUS()是一个宏观的。

有关它是如何运作的,你可能会想看看它在附带的C编译器的头。

For how it works you might like to look it up in the headers that come with your C-compiler.

的实施可能会有所不同从一个C编译器到其他。

The implementation might differ from one C-compiler to the other.

逐字从 waitpid函数()的POSIX规范

Verbatim from waitpid()'s POSIX specification:

如果WIFEXITED(stat_val)的值不为零,则该宏计算结果为低位的状态参数的8位是通过子进程_exit()或exit(),或值的子进程从返回
                主要的()。

If the value of WIFEXITED(stat_val) is non-zero, this macro evaluates to the low-order 8 bits of the status argument that the child process passed to _exit() or exit(), or the value the child process returned from main().

背后某个特定的程序中加入了回报code(S?)的动机是唯一已知的code的作者和希望现有的文件。


The motivation behind adding up the return code(s?) of a particular program is only known to the code's author and the hopefully existing documentation.

这篇关于什么WEXITSTATUS(状态)的回报?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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