[prev in list] [next in list] [prev in thread] [next in thread] 

List:       uclibc
Subject:    Re: [PATCH] bits/waitstatus.h: correctly interpret status 0x007f
From:       James Hogan <james () albanarts ! com>
Date:       2013-06-28 21:51:08
Message-ID: CAAG0J98Mvt1KiAn4P4Nq+w3mxuRqu34_N5brPb9vC_TrZXGZ0w () mail ! gmail ! com
[Download RAW message or body]

On 28 June 2013 22:16, Denys Vlasenko <vda.linux@googlemail.com> wrote:
> I'm not sure we really want this (it adds double evaluation in WIFSTOPPED macro),
> but this waitpid status does happen on MIPS.
>
> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>

This patch looks correct and optimal to me.

Thanks
James

> ---
>  libc/sysdeps/linux/common/bits/waitstatus.h |   14 +++++++++-----
>  1 files changed, 9 insertions(+), 5 deletions(-)
>
> diff --git a/libc/sysdeps/linux/common/bits/waitstatus.h b/libc/sysdeps/linux/common/bits/waitstatus.h
> index 45d0fd3..fbca0d2 100644
> --- a/libc/sysdeps/linux/common/bits/waitstatus.h
> +++ b/libc/sysdeps/linux/common/bits/waitstatus.h
> @@ -24,7 +24,7 @@
>  /* Everything extant so far uses these same bits.  */
>
>
> -/* If WIFEXITED(STATUS), the low-order 8 bits of the status.  */
> +/* If WIFEXITED(STATUS), the low-order 8 bits of exit(N).  */
>  #define        __WEXITSTATUS(status)   (((status) & 0xff00) >> 8)
>
>  /* If WIFSIGNALED(STATUS), the terminating signal.  */
> @@ -36,12 +36,16 @@
>  /* Nonzero if STATUS indicates normal termination.  */
>  #define        __WIFEXITED(status)     (__WTERMSIG(status) == 0)
>
> -/* Nonzero if STATUS indicates termination by a signal.  */
> -#define __WIFSIGNALED(status) \
> -  (((signed char) (((status) & 0x7f) + 1) >> 1) > 0)
> +/* Nonzero if STATUS indicates termination by a signal.
> + * Note that status 0x007f is "died from signal 127", not "stopped by signal 0".
> + * This does happen on MIPS.
> + * The comparison is "< 0xff", not "< 0x7f", because WCOREDUMP bit (0x80)
> + * can be set too.
> + */
> +#define        __WIFSIGNALED(status)   (((unsigned)((status) & 0xffff) - 1U) < 0xffU)
>
>  /* Nonzero if STATUS indicates the child is stopped.  */
> -#define        __WIFSTOPPED(status)    (((status) & 0xff) == 0x7f)
> +#define        __WIFSTOPPED(status)    (((status) & 0xff) == 0x7f && ((status) & 0xff00))
>
>  /* Nonzero if STATUS indicates the child continued after a stop.  We only
>     define this if <bits/waitflags.h> provides the WCONTINUED flag bit.  */
_______________________________________________
uClibc mailing list
uClibc@uclibc.org
http://lists.busybox.net/mailman/listinfo/uclibc
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic