bug-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] [SV 63307] Unignore SIGPIPE in spawned children


From: Philip Guenther
Subject: Re: [PATCH] [SV 63307] Unignore SIGPIPE in spawned children
Date: Wed, 2 Nov 2022 06:34:33 -0900

make should note whether SIGPIPE is ignored on entry and, if so, then it should leave it ignored when it invokes other programs and not unconditionally set SIGPIPE to SIGDFL.

Philip Guenther


On Wed, Nov 2, 2022 at 6:29 AM Andreas Schwab <schwab@suse.de> wrote:
* configure.ac: Check for posix_spawnattr_setsigdefault.
* src/job.c (child_execute_job): Set SIGPIPE to default in the
child process.
---
 configure.ac |  2 +-
 src/job.c    | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index 9f688971..30eb2d55 100644
--- a/configure.ac
+++ b/configure.ac
@@ -134,7 +134,7 @@ AC_CHECK_FUNCS([strtoll strdup strndup stpcpy memrchr mempcpy umask mkstemp \
                 getgroups seteuid setegid setlinebuf setreuid setregid \
                 mkfifo getrlimit setrlimit setvbuf pipe strerror strsignal \
                 lstat readlink atexit isatty ttyname pselect posix_spawn \
-                posix_spawnattr_setsigmask])
+                posix_spawnattr_setsigmask posix_spawnattr_setsigdefault])

 # We need to check declarations, not just existence, because on Tru64 this
 # function is not declared without special flags, which themselves cause
diff --git a/src/job.c b/src/job.c
index b78f279c..621ff899 100644
--- a/src/job.c
+++ b/src/job.c
@@ -2305,6 +2305,11 @@ child_execute_job (struct childbase *child, int good_stdin, char **argv)
   /* We are the child.  */
   unblock_all_sigs ();

+  /* Unignore SIPIPE.  */
+#ifdef SIGPIPE
+  bsd_signal (SIGPIPE, SIG_DFL);
+#endif
+
 #ifdef SET_STACK_SIZE
   /* Reset limits, if necessary.  */
   if (stack_limit.rlim_cur)
@@ -2347,6 +2352,19 @@ child_execute_job (struct childbase *child, int good_stdin, char **argv)
   }
 #endif /* have posix_spawnattr_setsigmask() */

+  /* Unignore SIGPIPE.  */
+#ifdef HAVE_POSIX_SPAWNATTR_SETSIGDEFAULT
+  {
+    sigset_t mask;
+    sigemptyset (&mask);
+    sigaddset (&mask, SIGPIPE);
+    r = posix_spawnattr_setsigdefault (&attr, &mask);
+    if (r != 0)
+      goto cleanup;
+    flags |= POSIX_SPAWN_SETSIGDEF;
+  }
+#endif
+
   /* USEVFORK can give significant speedup on systems where it's available.  */
 #ifdef POSIX_SPAWN_USEVFORK
   flags |= POSIX_SPAWN_USEVFORK;
--
2.38.1


--
Andreas Schwab, SUSE Labs, schwab@suse.de
GPG Key fingerprint = 0196 BAD8 1CE9 1970 F4BE  1748 E4D4 88E3 0EEA B9D7
"And now for something completely different."


reply via email to

[Prev in Thread] Current Thread [Next in Thread]