pclose返回值为什么要和256比较

忘是亡心i 2021-12-17 08:34 472阅读 0赞

#include
#include
#include
#include

#include

int main(int argc, char *argv[])
{
int status;
pid_t pid;

  1. pid = fork();
  2. if (0 == pid)
  3. {
  4. exit(atoi(argv[1]));
  5. } else
  6. {
  7. wait(&status);
  8. printf("status = %d\n", status);
  9. if (WIFEXITED(status))
  10. {
  11. printf("WEXITSTATUS(status)=%d\n", WEXITSTATUS(status));
  12. }
  13. }
  14. return 0;

}
该程序运行结果
1680913-20190606192315222-1087338037.png

pclose的返回值就是这里wait(&status)中status的值。

转载于:https://www.cnblogs.com/huyang892/p/10986385.html

发表评论

表情:
评论列表 (有 0 条评论,472人围观)

还没有评论,来说两句吧...

相关阅读

    相关 重载为什么返回无关

    我以前和你一样,对java中为什么不能根据返回值进行重载,而只能根据方法的参数进行重载非常不理解。在网上看到各种答案都不能完全的说服我,直到有一天突然就想通了。 假设根据返