The return value ofsystem(),pclose(), or
waitpid()doesn't seem to be the exit value of my process...
or the exit value is shifted left 8 bits... what's the deal?
The man page is right, and so are you! If you read the man page for
waitpid() you'll find that the return code for the process is
encoded. The value returned by the process is normally in the top 16
bits, and the rest is used for other things. You can't rely on this
though, not if you want to be portable, so the suggestion is that you
use the macros provided. These are usually documented under
wait() or wstat.
Macros defined for the purpose (in `<sys/wait.h>') include (stat is
the value returned by waitpid()):
WIFEXITED(stat)
WEXITSTATUS(stat)
WIFSIGNALED(stat)
WTERMSIG(stat)
WIFSTOPPED(stat)
WSTOPSIG(stat)
WIFCONTINUED(stat)
WCOREDUMP(stat)
WIFSIGNALED(stat) is non-zero, this is non-zero if the process
|
UNIXguide.net
English to Visayan Cebuano Dictionary |
Suggest a Site
Visayan Cebuano to English Dictionary |