0
有一些像这样的代码:子进程的退出状态的含义
unsigned pid = waitpid(mPid, &status, WNOHANG);
mExitStatus = WEXITSTATUS(status);
获取像变量调试打印:
mExitStatus = 15
status = 3840
对于“mExitStatus = WEXITSTATUS(状态)” ,我得到以下说明
evaluates to the least significant eight bits of the return code of the child which terminated
3840 = F00; F is 15 which is assigned to mExitStatus
但问题是我怎么能用这个15来判断是否chi ld进程是否正确终止?
15是从3840.但3840是由linux进程返回?对此有何意义?
在一般描述中,我主要启动了4个child_process,运行4个测试。我想在我的主要判断这4个测试是否通过。所以我认为我需要对我的子进程的退出状态进行评估。
感谢
请记住,进程的“退出状态”是进程“main”函数返回的值或传递给“exit”函数的值。如何解释它,但传统上零用于“好”,任何非零值用于“不好”。 –
@JoachimPileborg所以它是我的代码的地方(我从别人的代码包)决定价值3840? – thundium
不,只有八个低位由子进程决定,值为'15'。其他位由系统设置。阅读例如['waitpid'](http://man7.org/linux/man-pages/man2/waitpid.2.html)手册页获取更多信息。 –