[uClibc] WEXITSTATUS
Joel Coltoff
joel at wmi.com
Thu Nov 21 16:08:11 UTC 2002
On Thu, 21 Nov 2002, Gerhard Uttenthaler wrote:
>
> Hello,
>
> some time ago I asked about the following, but got never any respond. So
> I try again...
>
> The WEXITSTATUS() macro should return the least significant 8 bits, but
> the implementation in "libc/sysdeps/linux/common/bits/waitstatus.h"
> return the higher 8bits:
> #define __WEXITSTATUS(status) (((status) & 0xff00) >> 8)
>
It's a misleading comment. What it means is the exit value in a program
is limited to 8 bits. You have broken the code. Try this.
main()
{
int status;
if ( fork() == 0 )
{
// Child - exits with a status of 0x104
// (status value == 0x00000400) and not
// 0x00010400
sleep(1); // don't exit before parent waits
exit(0x104);
}
wait(&status);
printf( "status = 0x%08x\n", status);
}
--
Joel Coltoff
What lies behind us and what lies before us are tiny matters
compared to what lies within us.
-- Oliver Holmes
More information about the uClibc
mailing list