public inbox for cygwin-patches@cygwin.com
 help / color / mirror / Atom feed
From: Corinna Vinschen <corinna-cygwin@cygwin.com>
To: cygwin-patches@cygwin.com
Subject: Re: [PATCH] Cygwin: pinfo: Align CTTY behavior to the statement of POSIX.
Date: Tue, 20 Dec 2022 19:14:35 +0100	[thread overview]
Message-ID: <Y6H7i5J+C2B179KX@calimero.vinschen.de> (raw)
In-Reply-To: <20221220124106.487-1-takashi.yano@nifty.ne.jp>

Hi Takashi,

On Dec 20 21:41, Takashi Yano wrote:
> POSIX states "A terminal may be the controlling terminal for at most
> one session."
> https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap11.html
> 
> However, in cygwin, multiple sessions could be associated with the
> same TTY. This patch aligns CTTY behavior to the statement of POSIX.
> 
> Signed-off-by: Takashi Yano <takashi.yano@nifty.ne.jp>
> ---
>  winsup/cygwin/fhandler/termios.cc | 6 +++++-
>  winsup/cygwin/mm/cygheap.cc       | 2 ++
>  winsup/cygwin/pinfo.cc            | 4 +++-
>  3 files changed, 10 insertions(+), 2 deletions(-)

Do you want to handle this as bug (3.4) or extension (3.5)?

> diff --git a/winsup/cygwin/pinfo.cc b/winsup/cygwin/pinfo.cc
> index e086ab9a8..749a4064c 100644
> --- a/winsup/cygwin/pinfo.cc
> +++ b/winsup/cygwin/pinfo.cc
> @@ -528,7 +528,9 @@ _pinfo::set_ctty (fhandler_termios *fh, int flags)
>  {
>    tty_min& tc = *fh->tc ();
>    debug_printf ("old %s, ctty device number %y, tc.ntty device number %y flags & O_NOCTTY %y", __ctty (), ctty, tc.ntty, flags & O_NOCTTY);
> -  if (fh && (ctty <= 0 || ctty == tc.ntty) && !(flags & O_NOCTTY))
> +  if (tc.getsid () && tc.getsid () != pid)
> +    ; /* Do not attach if another session already attached to the CTTY. */

I'm sure I'm missing something, but I'm a bit puzzled about the

  tc.getsid () != pid

test here.  If that's not the case, this process is the process group
leader and already has a controlling tty, isn't it?


Thanks,
Corinna

  reply	other threads:[~2022-12-20 18:14 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-20 12:41 Takashi Yano
2022-12-20 18:14 ` Corinna Vinschen [this message]
2022-12-21 10:23   ` Takashi Yano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Y6H7i5J+C2B179KX@calimero.vinschen.de \
    --to=corinna-cygwin@cygwin.com \
    --cc=cygwin-patches@cygwin.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).