From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22202 invoked by alias); 6 Aug 2015 05:07:04 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: X-Seq: 36004 Received: (qmail 7089 invoked from network); 6 Aug 2015 05:07:02 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.0 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:message-id:date:in-reply-to:comments :references:to:subject:mime-version:content-type; bh=Siv9O0Pvwb+rVt3U7uNJ0VKbI52R4bLcvG1QqtJVUfE=; b=DPETKwr8dsbphakq7TbIydVikSFMwgQGLFfZKglorGaxBg7faV+yhMyh2kSt4VhVrU 0cdvjOzcq9BLvIbxrQrD3XXUlR6Sz0rMUl3h3okSkivNRMcMzVzCZa0hEIJZtv/WZinS nWWNeGPYu1A7Z07F2wKppar8ugF5e19IE7Pm4bCdXNH0Jsig5+y5EvniiUTWZuWzncJp jMLVY7jbf0trAMhjFgsFW0x42HwpJMxe/rfiRYmR4sIEK6PTrhT6j60y6KtdPCuvVfWv d0+i8IdRkAZoaj85BH7w88uOEA1mVZXSRGR06SD1nZQPE0bxgjS2IaC2LH9PnffiWusg b43Q== X-Gm-Message-State: ALoCoQnenbbTR+UP/db3RZJ/LYFshP8gcwZ5LDb1dF85oJjQXiZ0eTpyzIYxDVTqAIJdq2+UN06u X-Received: by 10.60.47.169 with SMTP id e9mr11931912oen.70.1438837619793; Wed, 05 Aug 2015 22:06:59 -0700 (PDT) From: Bart Schaefer Message-Id: <150805220656.ZM18545@torch.brasslantern.com> Date: Wed, 5 Aug 2015 22:06:56 -0700 In-Reply-To: Comments: In reply to Mathias Fredriksson "Re: Deadlock when receiving kill-signal from child process" (Aug 6, 12:49am) References: <150803085228.ZM24837@torch.brasslantern.com> <150803135818.ZM24977@torch.brasslantern.com> <150804235400.ZM9958@torch.brasslantern.com> <150805085258.ZM17673@torch.brasslantern.com> <150805115249.ZM7158@torch.brasslantern.com> <150805132014.ZM7746@torch.brasslantern.com> X-Mailer: OpenZMail Classic (0.9.2 24April2005) To: zsh-workers@zsh.org Subject: Re: Deadlock when receiving kill-signal from child process MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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;