Why does wait() set status to 256 instead of the -1 exit status of the forked process?

前端 未结 5 1398
渐次进展
渐次进展 2020-12-01 21:36

I\'m trying to return an integer value from a child process.

However, if I use exit(1) i get 256 as the output. exit(-1)

5条回答
  •  广开言路
    2020-12-01 21:54

    See the documentation. First use WIFEXITED to determine whether it terminated normally (possibly with non-zero status). Then, use WEXITSTATUS to determine what the low-order 8 bits of the actual status are.

提交回复
热议问题