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

Re: $pipestatus broken?



Bart Schaefer wrote:
> On Dec 23, 11:11pm, Frank Terbeck wrote:
> } ...unless, of course, the loop just needs to be there to delay the RHS,
> } for the exit/reap to happen as you suggested.
>
> Hmm, this is getting a bit hairy.
>
> In the simple case { echo foo | read -E }, there is a single job table
> entry for "read" which is the group leader for the pipeline.
>
> In the loop case { echo foo | repeat 1; read -E } there is a job table
> entry for the loop which is the group leader, but a new entry is
> created for "read -E".  execpline() remembers the previous thisjob as
> the local "pj" and restores thisjob = pj at line 1619, but by that
> time it is too late -- waitjobs() has set thisjob = -1 for just long
> enough for zhandler() to call update_job(), which fails to update the
> pipestats because thisjob = -1 tells it there is no current job.
>
> The following seems to fix it, by telling waitjobs() what the previous
> job number was so it can be reset immediately.  There may still be a
> race condition that requires fiddling with signal blocks to make sure
> thisjob is correct at the time the zhandler() catches the signal, but
> if so this should at least allow the block/unblock to be localized.

Hm. I'm having a hard time following what's going on...

With this change, the test I posted in workers-30047 changes a bit.
Before, there were only lines that either looked like "1" or "0 0". Now
I'm getting "0 1", too.

"1" and "0 1" seem to happen way less now - both cases are in the 1%
area each. But maybe I'm just a little luckier, with respect to timing.

Regards, Frank



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