Вопрос

glibc documentation on process completion status states that the macro WEXITSTATUS returns the low order 8 bytes of the completion status.

Macro: int WEXITSTATUS (int status)

If WIFEXITED is true of status, this macro returns the low-order 8 bits of the exit status value from the child process.

However, /usr/include/sys/wait.h says:

# define WEXITSTATUS(status)    __WEXITSTATUS (__WAIT_INT (status))

And, /usr/include/bits/waitstatus.h mentions:

/* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */
#define __WEXITSTATUS(status)   (((status) & 0xff00) >> 8)

Unless my endian-ness concepts are all messed up, how is this the low-order 8 bits? Or is libc assuming that the data is kept in a small-endian way?

Нет правильного решения

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top