如何从子进程读取返回代码
How to read the return code from a child process
我使用fork和execv来执行子进程。在父程序中,我有这个:
int status;
wait(&status);
cout << "return code = " << status << endl;
将等待子进程终止,然后显示它的返回代码?
如果想获取指定子进程的状态,应该使用waitpid()。wait()
将返回第一个完成子进程的状态
是的,从我读到的来看应该是http://linux.die.net/man/2/wait
相关文章:
- 创建LinkedList退出,返回代码为-11(SIGSEGV)
- 为什么C++程序在太大时返回代码而不是答案?
- bash脚本在使用popen()时不返回代码以调用C ++程序
- 如何在C++中执行命令并获取命令的返回代码标准输出和标准
- NMAKE:致命错误 U1077:cl.exe 和 nmake.exe 返回代码'0x2'
- DoModal 主应用程序随机返回 -1 代码
- C++线程中调用 std::terminate 时程序返回代码
- IMMDevice::激活缺少接口的返回代码
- 退出应用并在 MFC 中返回代码
- 什么是线程锁返回代码值
- 引发异常与返回代码
- 为什么我的shell只检测0-255之间的返回代码
- waitpid/wexitstatus 返回 0 而不是正确的返回代码
- linux下的Boost Semaphores和EINTR返回代码
- 从std::thread获取返回代码
- 从本地类的 C++ 析构函数访问返回代码
- DLL 注册返回代码0x80029c4a
- 定义D3DERR_INVALIDCALL(D3D11CreateDevice的返回代码)的位置
- Windows 错误消息返回代码而不是消息
- 如何在DdeCallback函数中实现返回代码