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

Re: zargs with -P intermittently failing in zsh 5.9 and macOS



> 2022/05/28 1:10、Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>のメール:
> 
> On Thu, May 26, 2022 at 10:30 PM Jun T <takimoto-j@xxxxxxxxxxxxxxxxx> wrote:
>> 
>> 
>> When 'wait pid' calls getbgstatus(pid), it finds the entry with status=19
>> and returns it.
> 
> Even if it's correct to have two entries, it's wrong to return the
> least recent one.

Yes, of course, so we need to fix it.

>> So I guess we need to call addbgstatus() only if the process has actually
>> exited (or killed). If this is the case, better solution would be
>> (B) call addbgstatus() only if WIFEXITED() or WIFSIGNALED() is true.
>> This it the patch below.
> 
> Does that really work?  I would expect WIFSIGNALED to be true when
> each of WIFSTOPPED and WIFCONTINUED is also true, so it wouldn't
> change anything?  (There isn't any way to stop/continue without using
> a signal that I can think of.)

I've tried A, B, C, and it seems all of them work in the sense that
it solves the current zargs's problem, and 'make check' passes.
But I think A is insufficient, as you write.

I was thinking B is enough, because:
WIFEXITED: has exited spontaneously
WIFSIGNALED: has been killed by a signal
WIFSTOPPED: still alive but now stoeepd
WIFCONTINUED: has been stopped but now continued
So these 4 are mutually exclusive.
In the case of EXITED/SIGNALED, further call of wait3() will not report
the status of the process. So if we call addbgstatus() only for
EXITED/SIGNALED, then it records the final state of the process just
onece. How do you think?  Do you have a Mac for testing?

Or we can use both B and C, and add a DPUTS() if addbgstatus() is
called more than once for a single pid.



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