Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: PATCH: subshell into a new process group
- X-seq: zsh-workers 54514
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Anthony Heading <ajrh@xxxxxxxx>
- Cc: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Re: PATCH: subshell into a new process group
- Date: Sat, 9 May 2026 21:43:55 -0700
- Arc-authentication-results: i=1; mx.google.com; arc=none
- Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20240605; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=KkHDOw8EvbsfZu1JF6kcGMuKaaTE+3X4kB57LEUKtPQ=; fh=cOsuM/DSAPz+Esg9LJ/IO8tbL30dysT8ilZRonPDrYM=; b=CkfSI4vu3r1w02Gm93BOntjFV9ADoxJmWBKJfL48ilLrQSjfA/uaRRUMNHTCfLroYG 4RAHoccWso/CWOl3a6EJX9RqlquG583WPmIs8WD6h7nb3tJkJkjqOeXHPK+qddjAt2yM 1ENku4vaFHjtYCr0tesSnk3RSpMQlPS8iyBaQDyyu+lUkx8NyaK3JyI6JJXzWC2Gq2Px r9G9V9V1UdrVynRDrqLMqu0C9HfmYOkOzBh8G8/IsX4MTg0mWRJh8gTFAVs3jMkXQHHP +PLtuRlLgnWYhAtmtns/8VaGOKIkgq1hsKEXEN8Gnee2n8cDP/+aRVGddmOe4C5Bvx9L G9qQ==; darn=zsh.org
- Arc-seal: i=1; a=rsa-sha256; t=1778388247; cv=none; d=google.com; s=arc-20240605; b=FABb9Gv6EXcHNHZ2HbHN/btpsypecW5thW0EH/N8khZj34c9UyMm5ZsRjt0sd9m35z XSP+ApBdWF4JA13czgwjv73tnm6xRzMiKjPyUeQubrUST/57LrBRzBfCm+ZWNVTynkuc MNyx03588XoYiZKzbb1/4joIMKPeu41T8K165ODNkuKTyfwHAaHtq4M6tM3NQPadoMED dP1r6nakvzD38s1gGExSmi56DKTySfB6zzre9YPlcrNGRh3R8JYBpWJOdHzAViql40Ip RNqAFY9DU2k+QFl1aj+S+29VCcZUgd7vn4PcxmWTJUJmn6FL5yx/NZOqRMf5K/1QaY7O nI9g==
- Archived-at: <https://zsh.org/workers/54514>
- In-reply-to: <9aaad53b-da59-4e32-86a2-d496438cb05d@app.fastmail.com>
- List-id: <zsh-workers.zsh.org>
- References: <c8058f0e-45c1-4c24-b607-70b64101b692@app.fastmail.com> <CAH+w=7ZujXuY1z9RV_L7CFzdqH7rBmZF+wBksWzBm16EAHGs-w@mail.gmail.com> <9aaad53b-da59-4e32-86a2-d496438cb05d@app.fastmail.com>
On Sat, May 9, 2026 at 4:44 PM Anthony Heading <ajrh@xxxxxxxx> wrote:
>
> On Sun, May 10, 2026, at 2:29 AM, Bart Schaefer wrote:
> > Not at a shell right now but I'm pretty sure the way to do this is
> > ( print this is a new pgrp ) &!
>
> I believe I'd found this only works in MONITOR mode
Indeed.
> For non-interactive shells, I don't think that & vs &! makes any
> difference, it just affects whether the job escapes the job table and
> thus avoids being SIGHUPed and so on. [...] 'disown' does feel like
> the broad purpose is to push the child out of the nest.
Hm, that raises an interesting point -- the "disown" builtin can't
force the child to change process groups. That would mean &! gets a
separate special meaning.
> But it would seem intuitive that your idea should work. Do we imagine
> anyone currently uses &! in a non-interactive shell and expects the
> subshell would stay in the same process group?
>
> So maybe something like the attached?
Aside: I'm not sure it matters, but other uses of setpgrp have 0L
rather than just 0. Also, please don't use multibyte unicode in the
comments (em-dash, I think?).
I don't think it needs a new ESUB flag. I've tried several test cases
and can't find any way in which the following results in materially
different behavior (other than the intended). Anyone? With this, the
process group has already been changed before "disown". If this
change is applied, we might also want to consider adding
$sysparams[pgid] to zsh/system.
Apologies if this gets unfortunate line-wrapping.
diff --git a/Src/exec.c b/Src/exec.c
index 60075f254..2f044cb9a 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -1099,6 +1099,8 @@ entersubsh(int flags, struct entersubsh_ret *retp)
if (flags & ESUB_ASYNC) {
settrap(SIGINT, NULL, 0);
settrap(SIGQUIT, NULL, 0);
+ if (flags & ESUB_PGRP)
+ setpgrp(0L, 0L);
if (isatty(0)) {
close(0);
if (open("/dev/null", O_RDWR | O_NOCTTY)) {
Messages sorted by:
Reverse Date,
Date,
Thread,
Author