From cb27bd35b5f870533b405db9c33d4a3b9a6314de Mon Sep 17 00:00:00 2001
From: Bruno Haible <bruno@clisp.org>
Date: Tue, 17 Jan 2023 15:15:57 +0100
Subject: [PATCH] execute tests: Avoid test failure on Android.

* tests/test-execute-main.c (main): Reset the SIGPIPE handler to
default.
---
 ChangeLog                 |  6 ++++++
 tests/test-execute-main.c | 12 ++++++++++++
 2 files changed, 18 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 6ef5f6d172..42e60a9be7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2023-01-17  Bruno Haible  <bruno@clisp.org>
+
+	execute tests: Avoid test failure on Android.
+	* tests/test-execute-main.c (main): Reset the SIGPIPE handler to
+	default.
+
 2023-01-17  Bruno Haible  <bruno@clisp.org>
 
 	hard-locale: Port to Android ≥ 5.0.
diff --git a/tests/test-execute-main.c b/tests/test-execute-main.c
index d89b34465b..fbaa9c9d2e 100644
--- a/tests/test-execute-main.c
+++ b/tests/test-execute-main.c
@@ -58,6 +58,18 @@ main (int argc, char *argv[])
   const char *progname = "test-execute-child";
   int test = atoi (argv[2]);
 
+#if defined __ANDROID__
+  /* On Android 11, when this test is executed through 'make' (GNU make 4.4) and
+     build-aux/test-driver, i.e. through
+       make check TESTS=test-execute.sh
+     or
+       rm -f test-execute.sh.log; make test-execute.sh.log
+     the signal handler for SIGPIPE is set to SIG_IGN.  This causes the tests
+     3 and 4 to fail.  Work around it by resetting the signal handler for
+     SIGPIPE to the default.  */
+  signal (SIGPIPE, SIG_DFL);
+#endif
+
   switch (test)
     {
     case 14:
-- 
2.39.5