From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-3.3 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED autolearn=ham autolearn_force=no version=3.4.4 Received: (qmail 16815 invoked from network); 8 Nov 2022 05:03:35 -0000 Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368) by inbox.vuxu.org with ESMTPUTF8; 8 Nov 2022 05:03:35 -0000 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1667883815; b=QTV+FSsn734DBiz7ZMNKJPAbMvvZmVcIlQff02ZUjDw69Ph98+DR2XG8m2SERnSGC24S1ElEn6 OgDcalEC41howYlacq0ZGgqHtor6y3LmPmWvKrTeXqbNu2Y8u6HqJVDsgaHlYdGQJrv5QejGBf +7Im4Zc2abPXxpEQe8DQwBoWJ/I99v/4diXMnmzOrkBMI0z3vCJSvVb1WYQbnYXnpKu/v75ck6 Cu7A/Pf/4cG8QqC9zwOM3BNK8qaYuKI9hWMLEUVrs8v2JD3UjAtuTaJpbmRgRaxiACHp90yb15 LUUSNG0RtanZPuPyBGExv/SQ/8GJ/kyq5k9EXRJTY16bGw==; ARC-Authentication-Results: i=1; zsh.org; iprev=pass (mail-ej1-f45.google.com) smtp.remote-ip=209.85.218.45; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1667883815; bh=oDlc6fYRkhXA/OVs7GVBsE4aKPhfuPIt5Bhtr8KFF6k=; h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help: List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:DKIM-Signature:DKIM-Signature; b=P7FqstbdsqR7UUpFSSzw28GFLE1AWKCDL7BCh/zklbbYL4xKztzsh5UgEsyd9ysNw10FEJpERI 3U+vS3RM48Z8zTGaDki9urFdOrmnK4YEtnpyvKdvZ6jzo4d75WrIR1dYd1DpaPOMHypkGgkeMr oYC0NdmLzxvDvtkGnP8WMiNzGBwAbX0Lyqgy+WnCP1/o9lKZSpR8dBHKh9KFbkGvfSxO/sS2SY tdWeuxSglFb4T39M1Co1J12tQRRSnKltWAeDvIvm1OPTTk0niWt1iz6e8FnzHRHLbaWYZlOHD/ mzPCSNEk57MtgJul0AfPHQAfh3PfMbIcD3OT3NMBluX8bg==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=zsh.org; s=rsa-20210803; h=List-Archive:List-Owner:List-Post:List-Unsubscribe: List-Subscribe:List-Help:List-Id:Sender:Content-Type:Cc:To:Subject:Message-ID :Date:From:In-Reply-To:References:MIME-Version:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID; bh=m2C5y3FSrxYkyhhtjja/cUWLj1KHaCoBwolYHYoJtgQ=; b=YnJai1pqaOlT25wC6HBWEWvv+p lg2+1JrDtDyrKmQqR+yuiYs57JulQtPw8aI6/dZAYj+yLvClFpp0p38DQG6/qDXufOdLM5wx8IWki AjjAz3iAftM2MfrZxuRFzQkANfAyZwVclDoNagphBW9GhbYrgg6Vwsq2jksi6Q04vkDHH8zuASvXJ P705QtfgtpU87/jhOZerZm9jzUS2S4NKRy5145PvShkJiLozuI8sOxvSYN1ZY5w5itWAPpeiqdOZM 5muO+XlTU/wrpWNcujyoXEhicNpRI2eblMamzqCjgP9HG6mAQpq2jbKFnYwmO9JurnTQDouVicIiq k9YSlplg==; Received: by zero.zsh.org with local id 1osGlq-0001Vo-Ra; Tue, 08 Nov 2022 05:03:34 +0000 Authentication-Results: zsh.org; iprev=pass (mail-ej1-f45.google.com) smtp.remote-ip=209.85.218.45; dkim=pass header.d=brasslantern-com.20210112.gappssmtp.com header.s=20210112 header.a=rsa-sha256; dmarc=none header.from=brasslantern.com; arc=none Received: from mail-ej1-f45.google.com ([209.85.218.45]:38817) by zero.zsh.org with esmtps (TLS1.3:TLS_AES_128_GCM_SHA256:128) id 1osGla-00019m-3i; Tue, 08 Nov 2022 05:03:19 +0000 Received: by mail-ej1-f45.google.com with SMTP id f5so35616002ejc.5 for ; Mon, 07 Nov 2022 21:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=brasslantern-com.20210112.gappssmtp.com; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=m2C5y3FSrxYkyhhtjja/cUWLj1KHaCoBwolYHYoJtgQ=; b=k26CM/1++utH/TVDZvn1zpfwqeFucwiQOSPxsvBxIcSYoKBnt9SlDGjviAO4uD4/oi S94DmtMf8LNE7bejCQ59IyPdZaiOqgTOwU+d+8N3kJFIY1AYBhXmzaOplvbPg8Z9b8SR ic6Iq0btd7qSvBZUq2QDrsJT8BDGmVNo9L4Rurv71RS8D6mZNox3JSsRKq8G2GDJux48 O+uG+JibUTjcQvkLLwTPelYuYbuBgGYLwHElefzCuL9cECxhRA6gMVDFfZ16Ua8jEK0Q TR8c3s696br2z5qNClSQe+yzJzOqUTWhLAF+XWxZugrVqkpaWO3t5tcG5ua/CRdB3x/1 9BqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=m2C5y3FSrxYkyhhtjja/cUWLj1KHaCoBwolYHYoJtgQ=; b=M67ePikuZs2w8oRavQw6NSAy3f2RQ2EtIwejVp3ctByuYOXqf113wQXhUzzrJTwvLk Q9Imqve0U4sRibeMo6UEyDKrQ5feGvyYnSFSKGotBbzy5AvqLgGuTAHCa3foHuVglYdV YKRNUWmcI1uSe+TmVGVxSJtKkeuNpcgI+Rn0uVop2RymhKNg9zLuhhjRvpOT8iZ6GUkQ wcQq6jouqMLahUiYg+ZjaI7mACTNbxN0M0geK5EvgdjUb6KDmrFyqrKt5skHM8gIOAEY 56G609RuwcOMtnPuA7umh0sveopPHOWzoHjvwsOp3vq1hKZQ8M1019Oeh7rj6lWznjeU QNuw== X-Gm-Message-State: ANoB5pm23cOdv/cBe4I1vMSJsLDqyk6h4dtsCsbIAdADOZjxWCypKBR3 qNw5ZDPdA+W17MTjpRttDb7gr0z8StbbP1Ern6YxiQ== X-Google-Smtp-Source: AA0mqf58gKaxcOoMbjKmN32KBpblYa9o/SAKiZQS5CEbAyrUBFZsHIllc4dCp7izFkzPW3Wj45bgN0+UvwFmf8OsOB0= X-Received: by 2002:a17:907:94cc:b0:7ae:7ff6:8ccf with SMTP id dn12-20020a17090794cc00b007ae7ff68ccfmr459201ejc.450.1667883797729; Mon, 07 Nov 2022 21:03:17 -0800 (PST) MIME-Version: 1.0 References: <2FE96386-2D04-434F-AD2F-F08356B1AE04@kba.biglobe.ne.jp> <7BB37CE7-16A2-4079-956B-802E3FB4DC82@kba.biglobe.ne.jp> <0A744179-81FA-4405-857D-6FFBE8F8FA1E@kba.biglobe.ne.jp> In-Reply-To: From: Bart Schaefer Date: Mon, 7 Nov 2022 21:03:06 -0800 Message-ID: Subject: Re: [PATCH] problem with 'ls | less' shell function To: Jun T Cc: zsh-workers@zsh.org Content-Type: text/plain; charset="UTF-8" X-Seq: 50911 Archived-At: X-Loop: zsh-workers@zsh.org Errors-To: zsh-workers-owner@zsh.org Precedence: list Precedence: bulk Sender: zsh-workers-request@zsh.org X-no-archive: yes List-Id: List-Help: , List-Subscribe: , List-Unsubscribe: , List-Post: List-Owner: List-Archive: On Mon, Nov 7, 2022 at 4:44 PM Bart Schaefer wrote: > > the location of the busy-loop is always > the same. I'm sure someone is going to explain to me why the following is wrong. If we're in the subshell and we just came back from being suspended, why would we not resume the current job? What happens with the patch below is that in the right side of the pipeline, after the new subshell is created upon ^Z, "fg" resumes the previous foreground job (the earlier job in the right-side brace construct) and the new subshell remains stopped until that job finishes, at which point it is resumed and proceeds with the next job in the braces. There are still some oddball race conditions. Depending on exactly when the ^Z is sent, and particularly after the left-side job has finished, the resumed right-side can become unkillable again. But that doesn't always happen. diff --git a/Src/exec.c b/Src/exec.c index c8bcf4ee5..b0f42ae67 100644 --- a/Src/exec.c +++ b/Src/exec.c @@ -1899,8 +1899,12 @@ execpline(Estate state, wordcode slcode, int how, int last1) break; } } - else if (subsh && jn->stat & STAT_STOPPED) - thisjob = newjob; + else if (subsh && jn->stat & STAT_STOPPED) { + if (thisjob == newjob) + makerunning(jn); + else + thisjob = newjob; + } else break; }