Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: deadlock caused by gettext usage in a signal handler



Le Tue, 4 Dec 2007 20:30:17 +0000,
Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx> a écrit :

> That leaves me wondering if forking might be
> the problem; do we need to queue signals around there?  It's not obvious
> why that would be.

It appears that glibc's fork is playing with locks:

http://sourceware.org/cgi-bin/cvsweb.cgi/libc/nptl/sysdeps/unix/sysv/linux/fork.c?rev=1.11.2.3&content-type=text/x-cvsweb-markup&cvsroot=glibc

This patch solved the problem for me:

diff --git a/Src/exec.c b/Src/exec.c
index cf79ea8..6f16b9e 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -229,6 +229,7 @@ zfork(struct timeval *tv)
 {
     pid_t pid;
     struct timezone dummy_tz;
+    sigset_t signals;
 
     /*
      * Is anybody willing to explain this test?
@@ -239,7 +240,10 @@ zfork(struct timeval *tv)
     }
     if (tv)
 	gettimeofday(tv, &dummy_tz);
+    sigfillset(&signals);
+    signals = signal_block(signals);
     pid = fork();
+    signal_setmask(signals);
     if (pid == -1) {
 	zerr("fork failed: %e", errno);
 	return -1;

Thanks.

-- 
Guillaume



Messages sorted by: Reverse Date, Date, Thread, Author