Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Removing subshell from zargs (see "zargs with -P intermittently failing")



Sorry I missed this post. And I fear I will not be able to going into
any detail at least for a few days.

> 2022/05/30 5:56, Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> 
> However, I also intermittently get this:
> 
> % zargs -n 1 -P 19 -- {1..40} -- f
> % jobs
> [1]    running    sleep 60
> [9]  + done       { "${call[@]}"; }
> 
> Or even this:
> 
> % zargs -n 1 -P 19 -- {1..40} -- f
> %
> [1]    done       sleep 60
> % jobs
> [9]  + done       { "${call[@]}"; }

(1) On my Mac, it seems that this does not happen if I start zsh by
'zsh -f' (but I don't know why).

(2) It seems we don't need the extra background job 'sleep 60 &'
to get the problem.

(3) I tried the following dirty patch for debugging:

diff --git a/Src/jobs.c b/Src/jobs.c
index a91ef787f..6e59b5b71 100644
--- a/Src/jobs.c
+++ b/Src/jobs.c
@@ -2391,7 +2391,8 @@ bin_fg(char *name, char **argv, Options ops, int func)
 		curmaxjob = maxjob;
 		ignorejob = thisjob;
 	    }
-	    for (job = 0; job <= curmaxjob; job++, jobptr++)
+	    for (job = 0; job <= curmaxjob; job++, jobptr++) {
+		zwarn("%d %d", job, jobptr->stat);
 		if (job != ignorejob && jobptr->stat) {
 		    if ((!OPT_ISSET(ops,'r') && !OPT_ISSET(ops,'s')) ||
 			(OPT_ISSET(ops,'r') && OPT_ISSET(ops,'s')) ||
@@ -2400,6 +2401,7 @@ bin_fg(char *name, char **argv, Options ops, int func)
 			(OPT_ISSET(ops,'s') && jobptr->stat & STAT_STOPPED))
 			printjob(jobptr, lng, 2);
 		}
+	    }
 	    unqueue_signals();
 	    return 0;
 	} else {   /* Must be BIN_WAIT, so wait for all jobs */


When the problem occurs, I get:

% zargs -n 1 -P 19 -- {1..40} -- f; jobs
zsh: 0 0
zsh: 1 17504	# thisjob = ignorejob
zsh: 2 0
zsh: 3 0
zsh: 4 0
zsh: 5 0
zsh: 6 0
zsh: 7 0
zsh: 8 2137
[8]  + done       { "${call[@]}"; }

2137 = 0x859
= STAT_CHANGED | STAT_DONE | STAT_LOCKED | STAT_INUSE | STAT_NOSTTY

maxjob = 8 here, but it should have been decremented to 1?
The only place maxjob is decremented is in freejob(), I guess.





Messages sorted by: Reverse Date, Date, Thread, Author