Apple/BSD:来自 waitpid 的状态 = 2943?
我正在跟踪一个进程。在 fork/execl 和子进程 wait
之后,我得到的状态为 2943。我正在测试失败,但 waitpid
报告没有失败。我查看了
,但该值未定义并且似乎不是位掩码。
关于我应该去哪里看有什么想法吗?
int DoParentProcess(int childPid)
{
int err, ret, status;
for( ; ; )
{
ret = waitpid(childPid, &status, 0);
err = errno;
///////////////////////////////////////
if(ret == -1)
{
cerr << "Failed to wait on child process, errno = " << err << endl;
return err;
}
///////////////////////////////////////
cout << "Parent: wait status = " << status << endl;
if(WIFEXITED(status))
break;
///////////////////////////////////////
ret = ptrace(PTRACE_CONT, childPid, 0, 0);
err = errno;
if(ret == -1)
{
cerr << "Failed to continue child process, errno = " << err << endl;
return err;
}
}
return 0;
}
I'm ptrace'ing a process. After fork/execl and then a wait
on the child, I'm getting a status of 2943. I'm testing for failure, but waitpid
reports non-failure. I've looked in <sys/wait.h>
, but the value is not defined and does not appear to be a bit mask.
Any ideas on where I should look?
int DoParentProcess(int childPid)
{
int err, ret, status;
for( ; ; )
{
ret = waitpid(childPid, &status, 0);
err = errno;
///////////////////////////////////////
if(ret == -1)
{
cerr << "Failed to wait on child process, errno = " << err << endl;
return err;
}
///////////////////////////////////////
cout << "Parent: wait status = " << status << endl;
if(WIFEXITED(status))
break;
///////////////////////////////////////
ret = ptrace(PTRACE_CONT, childPid, 0, 0);
err = errno;
if(ret == -1)
{
cerr << "Failed to continue child process, errno = " << err << endl;
return err;
}
}
return 0;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不应直接使用
waitpid
中的值。相反,应该使用提供的宏来提取相关位。例如,WIFEXITED
、WEXITSTATUS
和WTERMSIG
。The value from
waitpid
should not be directly used. Instead, the provided macros should be used to extract relevant bits. For example,WIFEXITED
,WEXITSTATUS
, andWTERMSIG
.