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

Re: Deadlock when receiving kill-signal from child process



I wrote:
} Yet another one of these.  We may have to resort to treating all signals
} the way we treat WINCH, that is, having them constantly queued except
} for specific moments when we unqueue them.

I played around with this a bit by hacking loop() but the effect is
that with the test script Mathais provided, most of the USR1 signals
are just thrown away (they collapse into a single call to the trap
handler).  Not sure if that's actually the desired effect.

On Aug 6, 12:49am, Mathias Fredriksson wrote:
}
} forked child:

You mean disowned, I presume, since all children are by definition forked.

} #18 0x000000010ba2bc12 in bld_eprog ()

Whack-a-mole continues.  Does the behavior change if you
	setopt NO_TRAPS_ASYNC
??

} #10 0x0000000106666885 in dotrapargs ()

The below might not be good enough -- it looks as if doshfunc() may need
to know internally about dont_queue_signals(), but other places that it is
called explictly unwrap it, so let's try that first.

Next question is how much are we slowing down the shell with all of this
signal management.


diff --git a/Src/parse.c b/Src/parse.c
index 09567fd..1a74164 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -488,6 +492,8 @@ bld_eprog(int heap)
     Eprog ret;
     int l;
 
+    queue_signals();
+
     ecadd(WCB_END());
 
     ret = heap ? (Eprog) zhalloc(sizeof(*ret)) : (Eprog) zalloc(sizeof(*ret));
@@ -511,6 +517,8 @@ bld_eprog(int heap)
     zfree(ecbuf, eclen);
     ecbuf = NULL;
 
+    unqueue_signals();
+
     return ret;
 }
 
diff --git a/Src/signals.c b/Src/signals.c
index 3950ad1..852f612 100644
--- a/Src/signals.c
+++ b/Src/signals.c
@@ -1219,6 +1219,10 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
     if (*sigtr & ZSIG_FUNC) {
 	int osc = sfcontext, old_incompfunc = incompfunc;
 	HashNode hn = gettrapnode(sig, 0);
+	int q;
+
+	queue_signals();	/* Any time we manage memory */
+	q = queue_signal_level();
 
 	args = znewlinklist();
 	/*
@@ -1244,11 +1248,14 @@ dotrapargs(int sig, int *sigtr, void *sigfn)
 
 	sfcontext = SFC_SIGNAL;
 	incompfunc = 0;
+	dont_queue_signals();
 	doshfunc((Shfunc)sigfn, args, 1);
+	restore_queue_signals(q);
 	sfcontext = osc;
 	incompfunc= old_incompfunc;
 	freelinklist(args, (FreeFunc) NULL);
 	zsfree(name);
+	unqueue_signals();
     } else {
 	trap_return = -2;	/* not incremented, used at current level */
 	trap_state = TRAP_STATE_PRIMED;



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