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.4 required=5.0 tests=DKIM_SIGNED,DKIM_VALID,
DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,
T_SCC_BODY_TEXT_LINE,UNPARSEABLE_RELAY autolearn=ham
autolearn_force=no version=3.4.4
Received: (qmail 7751 invoked from network); 28 Mar 2022 08:47:54 -0000
Received: from zero.zsh.org (2a02:898:31:0:48:4558:7a:7368)
by inbox.vuxu.org with ESMTPUTF8; 28 Mar 2022 08:47:54 -0000
ARC-Seal: i=1; cv=none; a=rsa-sha256; d=zsh.org; s=rsa-20210803; t=1648457274;
b=g3UT0XoYM1c/SCaLQhHCvic+6rZQIJ+QT1nexH/lNUXxSPS5/CxxnpMs/6lcoUEQ1OJIzEciT1
s0hLsr4ycxvGL5w4bkZ3uD9No1jgn8kOTY47dkoOVNEIKzHntRLCeNazUisF9KUJSY0dXbQWPA
2mU9bijYEehb5ISnUGmDqlYWX7nvl/5h1MsEqHWayEH3f1oEF6kNzraOnE2M8K6TCLNK/C3PBv
HqEvYTa17sWFyTF6juvYdAR2n+1gLI9X4s23HJ8rwHaxWWjQHSMKTEQ4ODJqE90+jHv4gD7ggY
ugEMJlJ7JYNV8/F9jjwXLALUWulwVrUikwJe9IepeBbrvQ==;
ARC-Authentication-Results: i=1; zsh.org;
iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=zsh.org; s=rsa-20210803; t=1648457274;
bh=Mrqn8xmkoqje6Xk0flEWJ7hblXInsNz9qVfHJHteIVE=;
h=List-Archive:List-Owner:List-Post:List-Unsubscribe:List-Subscribe:List-Help:
List-Id:Sender:Content-Transfer-Encoding:Content-Type:MIME-Version:Subject:
References:In-Reply-To:Message-ID:To:From:Date:DKIM-Signature:
DKIM-Signature;
b=e8VELJB9ondkBe6e+52ovuU2kXwXVqQHB2QSxpiXQVT5Y34BubSQSLg//g2EKcDO0fF1FB7RpV
g7XfpQckzDhgghheottKwKsQLy5LDOjeP/NSE7Oq8CkTOVfkKPyAEoyIq/sLsw+4iMtgmxdhVg
QZxy8h0YuM4aiGouaK06U19K4nX0bONJL9igKGF6MEbpCR5SagMrP64t24rXW+ug4tdM1omz69
fvmUR+1cl7ggfcEDjhioM0eW8fCZ3cc1l2REykrMzuNNDBaVP9EyagdWYAITDkT1mXe8IxWWFP
uAJ7CyCvlXRNOr2vFAanrf3nukuvZquJul4pzESmqFvOBg==;
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-Transfer-Encoding:
Content-Type:MIME-Version:Subject:References:In-Reply-To:Message-ID:To:From:
Date:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From:
Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID;
bh=XnhgYEiVihBZPAXyWtFC0zKgil76tYZA2hpO5xZ/erY=; b=m9S4GGYROctHdQPR1UWPhfueCO
M1wTi80gokWr9GOxgxkMEY82aFRP35nUe9ZIoA3k+5QhThUz4vlKi7ErEZoncMWb41dVTz/bxqNZ9
l+MS4SsKY0BiUfsFnrzX4B4XmFH+8ENbj7XMzQo36ixs7B9oE505zXkrvRsTRoCX3BAVZOeGHKAso
7hpaqKpD8goK+uHP0VaXmSmDpqYIf3WH1mwNIzyKpjEt2qFdGLp2vJoA7UFvGAqyCM5gcqcGWzfP1
y6SLd0aNatyPMSyEQwI3QqdEsQOlUPqoqZv0Ny+RSbGsLqfzMoA76C/yMjd/++QO0Gkuaky/KyJe5
NFk8hxsQ==;
Received: from authenticated user by zero.zsh.org with local
id 1nYl2W-0007es-K5; Mon, 28 Mar 2022 08:47:52 +0000
Authentication-Results: zsh.org;
iprev=pass (smtpq1.tb.ukmail.iss.as9143.net) smtp.remote-ip=212.54.57.96;
dkim=pass header.d=ntlworld.com header.s=meg.feb2017 header.a=rsa-sha256;
dmarc=pass header.from=ntlworld.com;
arc=none
Received: from smtpq1.tb.ukmail.iss.as9143.net ([212.54.57.96]:53076)
by zero.zsh.org with esmtps (TLS1.2:ECDHE-RSA-AES256-GCM-SHA384:256)
id 1nYl1y-0007KR-63; Mon, 28 Mar 2022 08:47:18 +0000
Received: from [212.54.57.80] (helo=smtp1.tb.ukmail.iss.as9143.net)
by smtpq1.tb.ukmail.iss.as9143.net with esmtp (Exim 4.90_1)
(envelope-from
)
id 1nYl1x-0005xx-O0
for zsh-workers@zsh.org; Mon, 28 Mar 2022 10:47:17 +0200
Received: from oxbe25.tb.ukmail.iss.as9143.net ([172.25.160.156])
by smtp1.tb.ukmail.iss.as9143.net with ESMTP
id Yl1xnDGvOBAYNYl1xnMT2B; Mon, 28 Mar 2022 10:47:17 +0200
X-Env-Mailfrom: p.w.stephenson@ntlworld.com
X-Env-Rcptto: zsh-workers@zsh.org
X-SourceIP: 172.25.160.156
X-CNFS-Analysis: v=2.4 cv=IZSU5Ema c=1 sm=1 tr=0 ts=62417615 cx=a_exe
a=NA7IgXeTfPXpJV+SL5V8Rw==:117 a=wbvTLvLwOfMA:10 a=IkcTkHD0fZMA:10
a=7H6ixmLU1AQA:10 a=q2GGsy2AAAAA:8 a=d5cuknKYy0G3RYxYRGMA:9 a=QEXdDO2ut3YA:10
a=z9dJwno5l634igLiVhy-:22
X-Authenticated-Sender: p.w.stephenson@ntlworld.com
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ntlworld.com;
s=meg.feb2017; t=1648457237;
bh=Mrqn8xmkoqje6Xk0flEWJ7hblXInsNz9qVfHJHteIVE=;
h=Date:From:To:In-Reply-To:References:Subject;
b=chyCm2o0Y2i+uJIFhqtxS6fYiF92Uay9t+PxA3JkPC6swyGuGoekOVuYFCZ/msKYu
6eAZAoXkWFS6oNzvGSsFp2w6t6vX1b97RMAoC2yS8zfGKwHf+xWoq4iTD0Fdi6NI+A
JLNlPbMDQSFhg0xOy9ixB9sgWF2Dhoac8SbB7fl142krcDTNJJJaln8RYBHNU/cOIk
m1flChbnvz6IbwjgwctItbEYSy3lGxlHBLHQNl9RbX0MU15hqtqDc+2y5H+zaHaTjv
OeUdWiDpQQauISP/n5VBTDunynrB6lFrb0O1U+UDo7wlC4k1yOPVhGBVVbD0kVYiCG
rFywbA5nJZeUg==
Date: Mon, 28 Mar 2022 09:47:17 +0100 (BST)
From: Peter Stephenson
To: Bart Schaefer ,
Zsh hackers list
Message-ID: <1409134730.698961.1648457237653@mail2.virginmedia.com>
In-Reply-To:
References:
Subject: Re: Crash on jobstates since workers/49783 (commit 6a8aa2a)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 7bit
X-Priority: 3
Importance: Medium
X-Mailer: Open-Xchange Mailer v7.8.4-Rev72
X-Originating-IP: 147.161.167.85
X-Originating-Client: open-xchange-appsuite
X-CMAE-Envelope: MS4xfMQyTFzbknNJmhdn47oP6XLDY+HSiIzLq5bCMlTBzcSNPgQWuJ/4qotmGfluAYNZUM1R+R6Vg0+LhpfxxuzZLi12CpMIlwiK0QCiURXqKp29iMC4xXju
xMANugYliaytpKHFDCNsYWKNiyKsrorVBYFyFvYgzm+eZX3UsYzLBUDodX6mKYTHSwP6XITzthzA26WOYLUBWN2/wz9j0e9FNSMQrF7W2N7LPNhcyBAvo2Uk
GFQMJ3K5nNKs65CVnLFHizxmW/OFOe7rYszrsELysww=
X-Seq: 49899
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 27 March 2022 at 06:34 Bart Schaefer wrote:
> On Fri, Mar 25, 2022 at 3:32 PM Bart Schaefer wrote:
> >
> > The nested calls to zargs from runN all die with a SEGV on when running:
> >
> > wait ${${jobstates[(R)running:*]/#*:/}/%=*/}
>
> Minimal reproducer:
>
> % sleep 5 &
> [1] 171363
> % ( wait ${${jobstates[(R)running:*]/#*:/}/%=*/} )
> zsh: segmentation fault (core dumped) ( wait
> ${${jobstates[(R)running:*]/#*:/}/%=*/}; )
> %
$jobstates was still looking at the process structures which doesn't
work in the subshell. Previously, it didn't even look at the
main job state in a subshell. Obviously, the subshell doesn't know
the up-to-date state anyway, and can't actually manipulate it.
So probably the best we can do is report the last we knew about the
job state and ignore the process structures. This probably warrants
a bit of documentation.
The code now reports "wait: can't manipulate jobs in subshell",
which I believe is a correct statement of affairs.
pws
diff --git a/Doc/Zsh/mod_parameter.yo b/Doc/Zsh/mod_parameter.yo
index 2e3011e44..28c19f797 100644
--- a/Doc/Zsh/mod_parameter.yo
+++ b/Doc/Zsh/mod_parameter.yo
@@ -189,6 +189,10 @@ the var(state) describes the state of that process.
Handling of the keys of the associative array is as described for
tt(jobdirs) above.
+
+This parameter is available in a subshell, but only shows overall job
+information, not process information. The information is current at the
+point the subshell forks from the parent shell.
)
vindex(nameddirs)
item(tt(nameddirs))(
diff --git a/Src/Modules/parameter.c b/Src/Modules/parameter.c
index dbb61e474..2692766eb 100644
--- a/Src/Modules/parameter.c
+++ b/Src/Modules/parameter.c
@@ -1348,6 +1348,15 @@ pmjobstate(Job jtab, int job)
else
ret = dyncat("running", cp);
+ if (jtab != jobtab)
+ {
+ /*
+ * This is a saved job table so doesn't have current
+ * process information --- bail out now.
+ */
+ return ret;
+ }
+
for (pn = jtab[job].procs; pn; pn = pn->next) {
if (pn->status == SP_RUNNING)