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

be2de2
diff --git a/debuginfod/debuginfod-client.c b/debuginfod/debuginfod-client.c
be2de2
index 18e7b85f..5ad6001b 100644
be2de2
--- a/debuginfod/debuginfod-client.c
be2de2
+++ b/debuginfod/debuginfod-client.c
be2de2
@@ -83,6 +83,7 @@ void debuginfod_end (debuginfod_client *c) { }
be2de2
 #include <sys/stat.h>
be2de2
 #include <sys/utsname.h>
be2de2
 #include <curl/curl.h>
be2de2
+#include <signal.h>
be2de2
 
be2de2
 /* If fts.h is included before config.h, its indirect inclusions may not
be2de2
    give us the right LFS aliases of these functions, so map them manually.  */
be2de2
@@ -1128,7 +1129,24 @@ debuginfod_set_progressfn(debuginfod_client *client,
be2de2
 /* NB: these are thread-unsafe. */
be2de2
 __attribute__((constructor)) attribute_hidden void libdebuginfod_ctor(void)
be2de2
 {
be2de2
+  /* The RHEL7 version of libcurl will muck with signal masks, messing up,
be2de2
+     e.g., gdb.  */
be2de2
+  sigset_t original_mask;
be2de2
+  struct sigaction original_actions[NSIG];
be2de2
+
be2de2
+  sigprocmask (0, NULL, &original_mask);
be2de2
+
be2de2
+  /* Some signal numbers in the range are invalid and might produce
be2de2
+     an error (EINVAL).  Simply ignore those, this is best effort.  */
be2de2
+  for (int i = 1; i < NSIG; ++i)
be2de2
+    sigaction (i, NULL, &original_actions[i]);
be2de2
+
be2de2
   curl_global_init(CURL_GLOBAL_DEFAULT);
be2de2
+
be2de2
+  for (int i = 1; i < NSIG; ++i)
be2de2
+    sigaction (i, &original_actions[i], NULL);
be2de2
+
be2de2
+  sigprocmask (SIG_SETMASK, &original_mask, NULL);
be2de2
 }
be2de2
 
be2de2
 /* NB: this is very thread-unsafe: it breaks other threads that are still in libcurl */