Popup_message_stop

NIIBE Yutaka gniibe at fsij.org
Thu Jan 24 05:22:29 CET 2013


On 2013-01-15 at 12:06 +0900, NIIBE Yutaka wrote:
> I am bitten by my own change of:
> 
>     commit f6251c0d0af92331388f5e9bcd1750cbadcaca8f
>     Author: NIIBE Yutaka <gniibe at fsij.org>
>     Date:   Fri Dec 16 09:07:56 2011 +0900
> 
>         Don't kill pinentry by SIGKILL but let it quit by SIGINT.
> 
>         * agent/call-pinentry.c (agent_popup_message_stop): To pinentry, send
>           SIGINT (was: SIGKILL).
> 
> The window of pinentry doesn't pop down, now.
> 
> This change was done because of pinentry-curses.  With
> pinentry-curses, when it is killed by SIGINT, terminal gets confused.
> 
> I figured out that the problem here is signal mask.  To handle
> signals, GPG-Agent has signal mask for SIGHUP, SIGUSR1, SIGUSR2,
> SIGINT and SIGTERM.  Then, pinentry will be fork/exec-ed with this
> signal mask, and SIGINT will not be delivered because of this mask.
> 
> We need to call pthread_atfork to unmask signals for child processes
> of GPG-Agent.
> 
> I'm not sure where to implement unmasking signals.
> 
> It should be GnuPG which calls pthread_atfork for 2.0 branch.  But
> it's common things among applications, it would be npth_sigev_fini
> which calls pthread_atfork for master branch.

Something like this.  It works for me.

diff --git a/src/npth-sigev.c b/src/npth-sigev.c
index f1271d1..aab977e 100644
--- a/src/npth-sigev.c
+++ b/src/npth-sigev.c
@@ -126,6 +126,13 @@ npth_sigev_add (int signum)
 }
 

+static void
+restore_sigmask_for_child_process (void)
+{
+  pthread_sigmask (SIG_SETMASK, &sigev_unblock, NULL);
+}
+
+
 /* Finish the list of watched signals.  This starts to block them,
    too.  */
 void
@@ -133,6 +140,7 @@ npth_sigev_fini (void)
 {
   /* Block the interesting signals.  */
   pthread_sigmask (SIG_SETMASK, &sigev_block, NULL);
+  pthread_atfork (NULL, NULL, restore_sigmask_for_child_process);
 }
 

-- 





More information about the Gnupg-devel mailing list