Re: PID-reuse races fix, introduced GCC validation brakage

Pedro Alves <[email protected]>
Newsgroups gmane.comp.sysutils.dejagnu.general
Message-ID <[email protected]>
On 03/31/2016 04:25 PM, Yvan Roux wrote:
> Hi Pedro,
> 
> On 31 March 2016 at 16:20, Pedro Alves <[email protected]> wrote:

> The regression is due to this part:
> 
> +    # Reap it.
> +    set res [catch "wait -i $program_id" wres]
> +    if {$exec_pid != -1} {
> +       # We reaped the process, so cancel the pending force-kills, as
> +       # otherwise if the PID is reused for some other unrelated
> +       # process, we'd kill the wrong process.
> +       exec sh -c "exec > /dev/null 2>&1 && kill -9 $exec_pid"
> +    }
> 
> In our case the "wait -i" command ends without any effect on the
> running processes 

"wait" just reaps an already zombie process.  So if that returns,
$program_id either already exited and is zombie, or wait
returned an error.

> and then it kills the command which was about to
> kill them, and the validation is stuck.
> 

So before my patch, the "wait -i" would also return immediately,
but it just happened that the "kill -15 $pgid" etc. commands kept
running in the background and ended up killing the processes
after the 5 / 10 seconds sleeps.  Correct?

How come the "wait -i" returns before _any_ process is
dead/zombie, as you say?  Did wait return an error?
I suspect that's something to do with taking the open path
instead of spawn, due to redirection.

And I wonder why the "kill -2 $pgid | kill -2 $pid" command didn't
cause "cat" to exit?

Thanks,
Pedro Alves
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.