From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6521 invoked by alias); 5 Aug 2015 15:53:10 -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: 35987 Received: (qmail 8156 invoked from network); 5 Aug 2015 15:53:08 -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=E9MH01Hs8FJAv68BKUskQsYsUx3MKRhk+V298ye1D3A=; b=Ty7rr/J7gg7+N5VgxGkCAm9zkWsNNlu6Uupk5ZtNj+UnUKpu7m6KUKjCA5wSflM/NO bx7OxIwDkJGLdiLBgePqotBDxTmv0BVLkup2+iqHPJx5uN76vOuI7DSlegP8fFFBhGyz Af3vE9f5QUw5DrGLsevGmt9bUhvnwT4EB4JE8Lw7yyfqLTMwsNxfylamUXKOqza89MQi jAhbx6xmd0OWGkOx2wsDxDMPNuBlyWCvtf2bk2JVlncQe76lPmSYJ6n2+NnuWmSKOYyh bbjl5FYANQXN94gG1C5360XrzmSapLt5hrd7acJRJlhSWEL3lVM6Nw4Swqr3OnhVUhpZ vYTw== X-Gm-Message-State: ALoCoQkIxt09zGvz8xInod3/CutJjoHRJWlSEQ1eP1BE9ZN3iyuYKrAOmTReqzWTHXgB+p1M/KOF X-Received: by 10.182.86.39 with SMTP id m7mr9090557obz.18.1438789983984; Wed, 05 Aug 2015 08:53:03 -0700 (PDT) From: Bart Schaefer Message-Id: <150805085258.ZM17673@torch.brasslantern.com> Date: Wed, 5 Aug 2015 08:52:58 -0700 In-Reply-To: Comments: In reply to Mathias Fredriksson "Re: Deadlock when receiving kill-signal from child process" (Aug 5, 1:37pm) References: <150803085228.ZM24837@torch.brasslantern.com> <150803135818.ZM24977@torch.brasslantern.com> <150804235400.ZM9958@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 On Aug 5, 1:37pm, Mathias Fredriksson wrote: } Subject: Re: Deadlock when receiving kill-signal from child process } } Of course, here's the output (as I see it in the terminal) with the } applied patch: } } TRAPUSR1:1: no job table entry for pid 61571 Aha. Well, we can't leave that zwarn() in there because there are legitimate cases where we fork without creating a job table entry, but none of those cases should have occurred with your test script. However, don't you delete it just yet from your test build. Instead, add this patch and see what you get. diff --git a/Src/exec.c b/Src/exec.c index 7612d43..29cc5cb 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1456,6 +1456,14 @@ execpline(Estate state, wordcode slcode, int how, int last1) else if (slflags & WC_SUBLIST_NOT) last1 = 0; + /* If trap handlers are allowed to run here, they may start another + * external job in the middle of us starting this one, which can + * result in jobs being reaped before their job table entries have + * been initialized, which in turn leads to waiting forever for + * jobs that no longer exist. So don't do that. + */ + queue_signals(); + pj = thisjob; ipipe[0] = ipipe[1] = opipe[0] = opipe[1] = 0; child_block(); @@ -1468,6 +1476,7 @@ execpline(Estate state, wordcode slcode, int how, int last1) */ if ((thisjob = newjob = initjob()) == -1) { child_unblock(); + unqueue_signals(); return 1; } if (how & Z_TIMED) @@ -1523,6 +1532,7 @@ execpline(Estate state, wordcode slcode, int how, int last1) else spawnjob(); child_unblock(); + unqueue_signals(); /* Executing background code resets shell status */ return lastval = 0; } else { @@ -1580,7 +1590,7 @@ execpline(Estate state, wordcode slcode, int how, int last1) } if (!(jn->stat & STAT_LOCKED)) { updated = hasprocs(thisjob); - waitjobs(); + waitjobs(); /* deals with signal queue */ child_block(); } else updated = 0; @@ -1588,6 +1598,8 @@ execpline(Estate state, wordcode slcode, int how, int last1) list_pipe_job && hasprocs(list_pipe_job) && !(jobtab[list_pipe_job].stat & STAT_STOPPED)) { child_unblock(); + unqueue_signals(); + queue_signals(); child_block(); } if (list_pipe_child && @@ -1672,6 +1684,7 @@ execpline(Estate state, wordcode slcode, int how, int last1) break; } child_unblock(); + unqueue_signals(); if (list_pipe && (lastval & 0200) && pj >= 0 && (!(jn->stat & STAT_INUSE) || (jn->stat & STAT_DONE))) { -- Barton E. Schaefer