@@ -0,0 +1,44 @@
+# bnc#481463
+#
+# Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=499569
+# agent/gpg-agent.c: Deinit the threading library before exec'ing
+# the command to run in --daemon mode. And because that still doesn't
+# restore the sigprocmask, do that manually. Closes: #499569
+#
+Index: gnupg-2.0.9/agent/gpg-agent.c
+===================================================================
+--- gnupg-2.0.9.orig/agent/gpg-agent.c 2009-03-18 14:20:12.000000000 +0100
++++ gnupg-2.0.9/agent/gpg-agent.c 2009-03-18 14:20:36.000000000 +0100
+@@ -490,6 +490,8 @@
+ int use_standard_socket = 0;
+ gpg_error_t err;
+ const char *env_file_name = NULL;
++ sigset_t initial_sigs;
++
+
+
+ set_strusage (my_strusage);
+@@ -499,6 +501,8 @@
+ somewhere after the option parsing */
+ log_set_prefix ("gpg-agent", JNLIB_LOG_WITH_PREFIX|JNLIB_LOG_WITH_PID);
+
++ sigprocmask(SIG_SETMASK, NULL, &initial_sigs);
++
+ /* Make sure that our subsystems are ready. */
+ init_common_subsystems ();
+
+@@ -1017,6 +1021,14 @@
+ kill (pid, SIGTERM );
+ exit (1);
+ }
++ if (! pth_kill())
++ {
++ log_error ("failed to clean up threading");
++ kill (pid, SIGTERM );
++ exit (1);
++ }
++ sigprocmask(SIG_SETMASK, &initial_sigs, NULL);
++
+ execvp (argv[0], argv);
+ log_error ("failed to run the command: %s\n", strerror (errno));
+ kill (pid, SIGTERM);
|