Blame SOURCES/elfutils-dts-curl-signal-state.patch

83db70
--- elfutils-0.187/debuginfod/debuginfod-client.c	2022-05-11 15:47:19.769601219 +0200
83db70
+++ elfutils-0.187/debuginfod/debuginfod-client.c.curl	2022-05-11 15:47:05.809805287 +0200
83db70
@@ -85,6 +85,7 @@
83db70
 #include <sys/stat.h>
83db70
 #include <sys/utsname.h>
83db70
 #include <curl/curl.h>
83db70
+#include <signal.h>
83db70
 
83db70
 /* If fts.h is included before config.h, its indirect inclusions may not
83db70
    give us the right LFS aliases of these functions, so map them manually.  */
83db70
@@ -105,7 +106,24 @@
83db70
 static void
83db70
 libcurl_init(void)
83db70
 {
83db70
+  /* The RHEL7 version of libcurl will muck with signal masks, messing up,
83db70
+     e.g., gdb.  */
83db70
+  sigset_t original_mask;
83db70
+  struct sigaction original_actions[NSIG];
83db70
+
83db70
+  sigprocmask (0, NULL, &original_mask);
83db70
+
83db70
+  /* Some signal numbers in the range are invalid and might produce
83db70
+     an error (EINVAL).  Simply ignore those, this is best effort.  */
83db70
+  for (int i = 1; i < NSIG; ++i)
83db70
+    sigaction (i, NULL, &original_actions[i]);
83db70
+
83db70
   curl_global_init(CURL_GLOBAL_DEFAULT);
83db70
+
83db70
+  for (int i = 1; i < NSIG; ++i)
83db70
+    sigaction (i, &original_actions[i], NULL);
83db70
+
83db70
+  sigprocmask (SIG_SETMASK, &original_mask, NULL);
83db70
 }
83db70
 
83db70
 struct debuginfod_client