Accepting request 1037051 from home:Andreas_Schwab:Factory

- reset-sigpipe.patch: Removed
- sigpipe-fatal.patch: Handle SIGPIPE as a fatal signal

OBS-URL: https://build.opensuse.org/request/show/1037051
OBS-URL: https://build.opensuse.org/package/show/Base:System/make?expand=0&rev=81
This commit is contained in:
Andreas Schwab 2022-11-21 09:41:39 +00:00 committed by Git OBS Bridge
parent 7eeeb3a310
commit 97e81fd2eb
4 changed files with 48 additions and 91 deletions

View File

@ -1,3 +1,9 @@
-------------------------------------------------------------------
Mon Nov 21 09:39:53 UTC 2022 - Andreas Schwab <schwab@suse.de>
- reset-sigpipe.patch: Removed
- sigpipe-fatal.patch: Handle SIGPIPE as a fatal signal
-------------------------------------------------------------------
Wed Nov 2 15:39:46 UTC 2022 - Andreas Schwab <schwab@suse.de>

View File

@ -27,7 +27,7 @@ Source: https://ftp.gnu.org/gnu/make/make-%{version}.tar.gz
Source1: https://ftp.gnu.org/gnu/make/make-%{version}.tar.gz.sig
# keyring downloaded from https://savannah.gnu.org/project/memberlist-gpgkeys.php?group=make&download=1
Source2: %{name}.keyring
Patch: reset-sigpipe.patch
Patch: sigpipe-fatal.patch
Patch64: make-library-search-path.diff
BuildRequires: pkgconfig
Requires(post): %{install_info_prereq}
@ -52,7 +52,7 @@ fi
%check
%make_build check || {
for f in tests/work/*/*.diff; do
for f in tests/work/*/*.diff*; do
test -f "$f" || continue
printf "++++++++++++++ %s ++++++++++++++\n" "${f##*/}"
cat "$f"

View File

@ -1,89 +0,0 @@
From 8a9e8592c9893385b5c4dd529f39333c7d7efab1 Mon Sep 17 00:00:00 2001
From: Andreas Schwab <schwab@suse.de>
Date: Wed, 2 Nov 2022 15:50:52 +0100
Subject: [PATCH] [SV 63307] Reset SIGPIPE in spawned children
* configure.ac: Check for posix_spawnattr_setsigdefault.
* src/job.c (child_execute_job): Reset SIGPIPE in the child
process.
* src/job.h (sigpipe_ignored): Declare.
* src/main.c (main): Remember if SIGPIPE was inherited as ignored.
---
configure.ac | 2 +-
src/job.c | 24 ++++++++++++++++++++++++
src/job.h | 2 ++
src/main.c | 2 +-
4 files changed, 28 insertions(+), 2 deletions(-)
Index: make-4.4/src/job.c
===================================================================
--- make-4.4.orig/src/job.c
+++ make-4.4/src/job.c
@@ -261,6 +261,10 @@ unsigned long job_counter = 0;
/* Number of jobserver tokens this instance is currently using. */
unsigned int jobserver_tokens = 0;
+
+/* Whether SIGPIPE was ignored on entry. */
+
+int sigpipe_ignored;
#ifdef WINDOWS32
@@ -2305,6 +2309,12 @@ child_execute_job (struct childbase *chi
/* We are the child. */
unblock_all_sigs ();
+ /* Unignore SIPIPE. */
+#ifdef SIGPIPE
+ if (!sigpipe_ignored)
+ bsd_signal (SIGPIPE, SIG_DFL);
+#endif
+
#ifdef SET_STACK_SIZE
/* Reset limits, if necessary. */
if (stack_limit.rlim_cur)
@@ -2347,6 +2357,18 @@ child_execute_job (struct childbase *chi
}
#endif /* have posix_spawnattr_setsigmask() */
+ /* Unignore SIGPIPE. */
+ if (!sigpipe_ignored)
+ {
+ sigset_t mask;
+ sigemptyset (&mask);
+ sigaddset (&mask, SIGPIPE);
+ r = posix_spawnattr_setsigdefault (&attr, &mask);
+ if (r != 0)
+ goto cleanup;
+ flags |= POSIX_SPAWN_SETSIGDEF;
+ }
+
/* USEVFORK can give significant speedup on systems where it's available. */
#ifdef POSIX_SPAWN_USEVFORK
flags |= POSIX_SPAWN_USEVFORK;
Index: make-4.4/src/job.h
===================================================================
--- make-4.4.orig/src/job.h
+++ make-4.4/src/job.h
@@ -88,5 +88,7 @@ pid_t exec_command (char **argv, char **
void unblock_all_sigs (void);
+extern int sigpipe_ignored;
+
extern unsigned int job_slots_used;
extern unsigned int jobserver_tokens;
Index: make-4.4/src/main.c
===================================================================
--- make-4.4.orig/src/main.c
+++ make-4.4/src/main.c
@@ -1184,7 +1184,7 @@ main (int argc, char **argv, char **envp
/* Don't die if our stdout sends us SIGPIPE. */
#ifdef SIGPIPE
- bsd_signal (SIGPIPE, SIG_IGN);
+ sigpipe_ignored = bsd_signal (SIGPIPE, SIG_IGN) == SIG_IGN;
#endif
#ifdef HAVE_ATEXIT

40
sigpipe-fatal.patch Normal file
View File

@ -0,0 +1,40 @@
From 92ab2e642d2c04b3dcb5a736ae6193680bfd5f74 Mon Sep 17 00:00:00 2001
From: Paul Smith <psmith@gnu.org>
Date: Sun, 6 Nov 2022 15:22:02 -0500
Subject: [PATCH] * src/main.c (main): [SV 63307] Handle SIGPIPE as a fatal
signal
Always ignoring SIGPIPE is visible to child processes.
---
src/main.c | 8 +++-----
1 file changed, 3 insertions(+), 5 deletions(-)
diff --git a/src/main.c b/src/main.c
index eec93656..f2caf7a8 100644
--- a/src/main.c
+++ b/src/main.c
@@ -1182,11 +1182,6 @@ main (int argc, char **argv, char **envp)
/* Useful for attaching debuggers, etc. */
SPIN ("main-entry");
- /* Don't die if our stdout sends us SIGPIPE. */
-#ifdef SIGPIPE
- bsd_signal (SIGPIPE, SIG_IGN);
-#endif
-
#ifdef HAVE_ATEXIT
if (ANY_SET (check_io_state (), IO_STDOUT_OK))
atexit (close_stdout);
@@ -1264,6 +1259,9 @@ main (int argc, char **argv, char **envp)
#endif
#ifdef SIGQUIT
FATAL_SIG (SIGQUIT);
+#endif
+#ifdef SIGPIPE
+ FATAL_SIG (SIGPIPE);
#endif
FATAL_SIG (SIGINT);
FATAL_SIG (SIGTERM);
--
2.38.1