On Mon, 9 Jan 2023 10:25:33 +0100
Corinna Vinschen wrote:
> On Dec 28 17:35, Takashi Yano wrote:
> > The commit 25c4ad6ea52f did not fix the CTTY behavior enough. For
> > example, in the following test case, TTY will be associated as
> > a CTTY on the second open() call even though the TTY is already
> > CTTY of another session. This patch fixes the issue.
>
> The patch is ok, thanks.
>
> But while looking into this patch, I realized how confusing the old code
> is. An unsuspecting reader will have a really hard time to figure out
> what ctty values of -1 or -2 actually mean. The CVS log entry from 2012
> isn't enlightening either:
>
> On second thought, in the spirit of keeping things kludgy, set ctty to
> -2 here as a special flag ...
>
> Would you mind to introduce speaking symbolic values for them and add
> some comments to make them more transparent?
Ok. Do you mean, first push this CTTY patch, then,
add comment for ctty values -1 and -2 in another patch?
> Also, given this was a "kludge" from 10 years ago, is it really still
> needed?
>
> As I said, it's confusing :}
Currently, the special values mean:
-1: CTTY is not initialized yet. Can associate with the TTY
which is associated with the own session.
-2: CTTY has been released by setsid(). Can associate with
a new TTY as CTTY, but cannot associate with the TTYs
already associated with other sessions.
So, I think the two different values are necessary.
--
Takashi Yano <[email protected]>