gpt4 book ai didi

c - 为什么 WIFEXITED 会在运行过程中返回 True?

转载 作者:太空狗 更新时间:2023-10-29 17:10:55 25 4
gpt4 key购买 nike

当我等待作为子进程的特定运行进程组时,WIFEXITED 返回 true 表示进程已退出?这是它的工作方式吗?似乎有一些我不理解的东西....

if ( waitpid(-pgid, &pstatus, WUNTRACED|WNOHANG ) == -1)
perror("Wait error");

if ( WIFEXITED(pstatus) ) {
strncpy(buf, "Exited", buf_size);
return 0;

最佳答案

正如您指定的 WNOHANG 我认为 waitpid 正在返回 0 并且 pstatus 具有它之前的值所以WIFEXITED 无法使用更新后的数据。

if WNOHANG was specified and one or more child(ren) specified by pid exist, but have not yet changed state, then 0 is returned.

关于c - 为什么 WIFEXITED 会在运行过程中返回 True?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1643210/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com