[PATCH] bits/waitstatus.h: correctly interpret status 0x007f

Denys Vlasenko vda.linux at googlemail.com
Sat Jun 29 21:55:18 UTC 2013


On Sat, Jun 29, 2013 at 10:12 PM, James Hogan <james.hogan at imgtec.com> wrote:
>> +/* Nonzero if STATUS indicates the child is stopped.
>> + * Low byte should be 0x7f and 2nd byte should be nonzero.
>> + * The condition is true if both bytes have at least one set bit in the same
>> + * position in bits 0-6, but at least one of 7th bits are clear
>> + * (because we must not match 0xffff == WCONTINUED).
>> + */
>> +#define        __WIFSTOPPED(status)    ((signed char)(((status) >> 8) & (status)) > 0)
>
> Sneaky. Of course it would match certain status codes which aren't
> strictly WIFSTOPPED (e.g. 0x0202, WIFSIGNALED && WTERMSIG==2).

There are many possible invalid combinations.
They are not supposed to be generated by the kernel, ever.


More information about the uClibc mailing list