bug-bash
[Top][All Lists]
Advanced

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

Re: give_terminal_to() / maybe_give_terminal_to() race


From: Earl Chew
Subject: Re: give_terminal_to() / maybe_give_terminal_to() race
Date: Thu, 31 Aug 2023 22:51:33 -0700
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Thunderbird/102.14.0

On 2023-08-30 07:39, Chet Ramey wrote:
OK, so there is a potential race condition here. What do you suggest the
right approach might be? It seems to me we can do one of two things:
rearrange and extend the PGRP_PIPE code to make sure the child process
doesn't proceed until the parent sets the terminal process group; or
change stop_pipeline() (and audit its callers, of course) so it does not
set the terminal process group.

I experimented a bit, and gave the matter some thought. The controlling
terminal must be reconfigured before the parent gets to wait() for the
job, and before the child gets to exec() the program (or their
equivalents). This means that there must be some synchronisation
to ensure that these conditions are true.

Either the parent must yield the controlling terminal, or the child
must acquire the controlling terminal, and the other must block
until the outcome has been achieved.

Since PGRP_PIPE supports the parent providing a synchronisation signal,
it aligns with the parent yielding the controlling terminal. Presently,
there is no mechanism for the child to trigger a synchronisation
with the parent. For this reason, I think the first option you list
is a more straightforward fit for the implementation.

Should I go ahead and propose a patch?

Earl


reply via email to

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