From 1cd342ac7d4460c8f717149bc8588186359c5c17 Mon Sep 17 00:00:00 2001 From: wiz Date: Sun, 6 Nov 2022 20:58:00 +0000 Subject: zsh: add candidate upstream patch for bg/fg issue with shell functions Bump PKGREVISION. --- shells/zsh/Makefile | 4 +-- shells/zsh/distinfo | 3 +- shells/zsh/patches/patch-Src_jobs.c | 70 +++++++++++++++++++++++++++++++++++++ 3 files changed, 74 insertions(+), 3 deletions(-) create mode 100644 shells/zsh/patches/patch-Src_jobs.c (limited to 'shells') diff --git a/shells/zsh/Makefile b/shells/zsh/Makefile index 0010d4fa67f..d7aee0b23b1 100644 --- a/shells/zsh/Makefile +++ b/shells/zsh/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.104 2022/07/01 23:31:49 rin Exp $ +# $NetBSD: Makefile,v 1.105 2022/11/06 20:58:00 wiz Exp $ DISTNAME= zsh-5.9 -PKGREVISION= 1 +PKGREVISION= 2 CATEGORIES= shells MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=zsh/} EXTRACT_SUFX= .tar.xz diff --git a/shells/zsh/distinfo b/shells/zsh/distinfo index badf6923765..d1342a1cebb 100644 --- a/shells/zsh/distinfo +++ b/shells/zsh/distinfo @@ -1,4 +1,4 @@ -$NetBSD: distinfo,v 1.78 2022/07/01 23:31:49 rin Exp $ +$NetBSD: distinfo,v 1.79 2022/11/06 20:58:00 wiz Exp $ BLAKE2s (zsh-5.9.tar.xz) = 1ab2ab9dd0debc176bdefd661b62e102153c26f591e35916ccc7527c337d0530 SHA512 (zsh-5.9.tar.xz) = d9138b7f379ad942a5f46819d2dd52d31f3a1129f2a0d1b53d4c5cd43c318b60396da6d37c57c477b8e958fb750209aca0ae93f8c9dd42ac958de006a0ff067e @@ -6,4 +6,5 @@ Size (zsh-5.9.tar.xz) = 3332400 bytes SHA1 (patch-Completion_BSD_Command___bsd__pkg) = fe0d9cc399fe185ce71a64431e4086ed07920cb8 SHA1 (patch-Completion_Unix_Command___gpg) = 8eba031838b1cfb0bfadf0fa539e760fd1cb539c SHA1 (patch-Config_installfns.sh) = ef0b250a0121c0e4925022e02553aefa23e6cc8d +SHA1 (patch-Src_jobs.c) = d4be7424283f22a5ce26ba6aebfe51f105c033ce SHA1 (patch-configure) = 1b757f0ba6611a206f2e9c4d3de5c11fc629a364 diff --git a/shells/zsh/patches/patch-Src_jobs.c b/shells/zsh/patches/patch-Src_jobs.c new file mode 100644 index 00000000000..e77fef1961b --- /dev/null +++ b/shells/zsh/patches/patch-Src_jobs.c @@ -0,0 +1,70 @@ +$NetBSD: patch-Src_jobs.c,v 1.1 2022/11/06 20:58:00 wiz Exp $ + +Candidate fix for shell function pipeline bg/fg issue, from +https://zsh.org/mla/workers/2022/msg01204.html + +--- Src/jobs.c.orig 2022-05-08 06:18:22.000000000 +0000 ++++ Src/jobs.c +@@ -544,16 +544,14 @@ update_job(Job jn) + + if (isset(MONITOR)) { + pid_t pgrp = gettygrp(); /* get process group of tty */ ++ int deadpgrp = (mypgrp != pgrp && inforeground && pgrp > 1 && ++ kill(-pgrp, 0) == -1 && errno == ESRCH); + + /* is this job in the foreground of an interactive shell? */ + if (mypgrp != pgrp && inforeground && +- (jn->gleader == pgrp || +- (pgrp > 1 && +- (kill(-pgrp, 0) == -1 && errno == ESRCH)))) { ++ ((jn->gleader == pgrp && signalled) || deadpgrp)) { + if (list_pipe) { +- if (somestopped || (pgrp > 1 && +- kill(-pgrp, 0) == -1 && +- errno == ESRCH)) { ++ if (somestopped || deadpgrp) { + attachtty(mypgrp); + /* check window size and adjust if necessary */ + adjustwinsize(0); +@@ -566,6 +564,12 @@ update_job(Job jn) + * when the job is finally deleted. + */ + jn->stat |= STAT_ATTACH; ++ /* ++ * If we're in shell jobs on the right side of a pipeline ++ * we should treat it like a job in the current shell. ++ */ ++ if (inforeground == 2) ++ inforeground = 1; + } + /* If we have `foo|while true; (( x++ )); done', and hit + * ^C, we have to stop the loop, too. */ +@@ -1488,10 +1492,7 @@ addproc(pid_t pid, char *text, int aux, + * set it for that, too. + */ + if (gleader != -1) { +- if (jobtab[thisjob].stat & STAT_CURSH) +- jobtab[thisjob].gleader = gleader; +- else +- jobtab[thisjob].gleader = pid; ++ jobtab[thisjob].gleader = gleader; + if (list_pipe_job_used != -1) + jobtab[list_pipe_job_used].gleader = gleader; + /* +@@ -1500,7 +1501,7 @@ addproc(pid_t pid, char *text, int aux, + */ + last_attached_pgrp = gleader; + } else if (!jobtab[thisjob].gleader) +- jobtab[thisjob].gleader = pid; ++ jobtab[thisjob].gleader = pid; + /* attach this process to end of process list of current job */ + pnlist = &jobtab[thisjob].procs; + } +@@ -2488,6 +2489,7 @@ bin_fg(char *name, char **argv, Options + jobtab[job].stat &= ~STAT_CURSH; + } + if ((stopped = (jobtab[job].stat & STAT_STOPPED))) { ++ /* WIFCONTINUED will makerunning() again at killjb() */ + makerunning(jobtab + job); + if (func == BIN_BG) { + /* Set $! to indicate this was backgrounded */ -- cgit v1.2.3