This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH 2/4] nptl: Handle EPIPE on tst-cancel2
- From: Adhemerval Zanella <adhemerval dot zanella at linaro dot org>
- To: libc-alpha at sourceware dot org
- Date: Thu, 15 Aug 2019 18:18:41 -0300
- Subject: [PATCH 2/4] nptl: Handle EPIPE on tst-cancel2
- References: <20190815211843.22799-1-adhemerval.zanella@linaro.org>
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;
}
--
2.17.1