This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 2/4] nptl: Handle EPIPE on tst-cancel2


I will push shortly if no one opposes it.

On 15/08/2019 18:18, Adhemerval Zanella wrote:
> The SIGPIPE can be handled before SIGCANCEL, which makes write fail
> and the thread return a non expected result.
> 
> Checked on x86_64-linux-gnu.
> 
> 	* nptl/tst-cancel2.c (tf): Do not abort with EPIPE.
> ---
>  nptl/tst-cancel2.c | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
> 
> diff --git a/nptl/tst-cancel2.c b/nptl/tst-cancel2.c
> index 1f0429d343..632ea4e0ae 100644
> --- a/nptl/tst-cancel2.c
> +++ b/nptl/tst-cancel2.c
> @@ -20,6 +20,7 @@
>  #include <signal.h>
>  #include <stdio.h>
>  #include <unistd.h>
> +#include <errno.h>
>  
>  
>  static int fd[2];
> @@ -32,7 +33,14 @@ tf (void *arg)
>       write blocks.  */
>    char buf[100000];
>  
> -  while (write (fd[1], buf, sizeof (buf)) > 0);
> +  while (1)
> +    {
> +      /* Ignore EPIPE errors for case the SIGPIPE is handle before
> +	 SIGCANCEL.  */
> +      ssize_t ret = write (fd[1], buf, sizeof (buf));
> +      if (ret == 0 || (ret == -1 && errno != EPIPE))
> +       break;
> +    }
>  
>    return (void *) 42l;
>  }
> 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]