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

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