I'm trying to return an integer value from a child process.
However, if I use exit(1)
I get 256
as the output from wait()
. Using exit(-1)
gives 65280
.
Is there a way I can get the actual int value that I send from the child process?
if(!(pid=fork()))
{
exit(1);
}
waitpid(pid,&status,0);
printf("%d",status);
Edit: Using exit(-1)
(which is what I actually want) I am getting 255 as the output for WEXITSTATUS(status)
. Is it supposed to be unsigned?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…