开发者

How to read the return code from a child process

开发者 https://www.devze.com 2023-02-28 19:17 出处:网络
I use fork and execv to execute a child process. In the parent program, I have this: int status; wait(&status);

I use fork and execv to execute a child process. In the parent program, I have this:

int status;
wait(&status);
cout << "return code = " << status << endl;

Will that wait for the child process to terminate and then display开发者_如何学JAVA it's return code?


You should use waitpid() if want to get status of specified child process. wait() will return status of first finished child process.


yes, it should from what i read http://linux.die.net/man/2/wait

0

精彩评论

暂无评论...
验证码 换一张
取 消