bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: wait -n misses signaled subprocess


From: Steven Pelley
Subject: Re: wait -n misses signaled subprocess
Date: Sun, 28 Jan 2024 19:19:06 -0500

Thank you Chet for your thorough reply.

You make a few comments about differences in output (stderr for not
finding a job, notifications for jobs terminating) and in all cases I
believe you are correct.  Let's assume job control is disabled.

> >
> > I expect the line ending (BUG) to indicate a return code of 143.
>
> It might, if `wait -n' looked for already-notified jobs in the table of
> saved exit statuses, but it doesn't. Should it, even if the user has
> already been notified of the status of that job?

When job control is disabled I get this output for the same test (just
for consistent reference):
TEST: KILL PRIOR TO wait -n @0
kill -TERM 526 @0
./test.sh: line 13: wait: 526: no such job
wait -n 526 return code 127 @2 (BUG)
wait 526 return code 143 @2
TEST: KILL DURING wait -n @2
kill -TERM 544 @3
wait -n 544 return code 143 @3
wait 544 return code 143 @3

There's no user notification of the job terminating because job
control is disabled.  The "wait -n" returning 127 is the first
opportunity the shell might have to notify the user of the job.  In
this context I think that "even if the user has already been notified
of the status of that job" doesn't apply -- the user hasn't been
notified of the job terminating.  It's possible you are saying that
the user was notified of the job's termination in some other way that
I missed, so please tell me if I'm misunderstanding this part.

Even so, this behavior differs from a similar example but where the
first job ends successfully, or at least without being killed by a
signal.  It still terminates prior to calling "wait -n" (this is from
Jan 24 but I'll post again to keep everything in a linear thread).
echo "TEST: EXIT 0 PRIOR TO wait -n @${SECONDS}"
{ sleep 1; echo "child finishing @${SECONDS}"; exit 1; } &
pid=$!
echo "child proc $pid @${SECONDS}"
sleep 2
wait -n $pid
echo "wait -n $pid return code $? @${SECONDS}"

output (no job control):
TEST: EXIT 0 PRIOR TO wait -n @0
child proc 2779 @0
child finishing @1
wait -n 2779 return code 1 @2

It does look in the table of saved exit statuses, returning 1.

I think the sticking point is the notion of the user being notified of
the status of a job.  In these examples I don't see that the user is
notified prior to the first call to "wait -n," and so I think that
this call should notify the user.  This first call to "wait -n" _does_
notify the user in the case that the job terminated by exiting (not
signalled), but _does not_ notify the user in the case that the job
was killed.

Steve



reply via email to

[Prev in Thread] Current Thread [Next in Thread]