I have seen similar questions here and here. The answers suggest to use WEXITSTATUS. But according to man page of WAIT(2), it has a limitation. It says: WEXITSTATUS(wstatus) returns the exit status of the child. This consists of the least significant 8 bits of the status argument that the child specified in a call to exit(3) or _exit(2) or as the argument for a return statement in main(). This macro should be employed only if WIFEXITED returned true.
So, if the child returns a value larger than 255, parent doesn't get the correct value. My question is how can a parent process receive the returned value which is larger than 255? Thanks