[PATCH] luit: Cygwin compatibility fix

Alan Coopersmith Alan.Coopersmith at Sun.COM
Tue Oct 6 13:02:50 PDT 2009


Looks good to me - thanks.

Reviewed-by: Alan Coopersmith <alan.coopersmith at sun.com>

	-alan-

Yaakov (Cygwin/X) wrote:
> From: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
> 
> Cygwin has O_NOCTTY but not TIOCSCTTY, so there is no way for the tty
> to become controlling this way.  Also, document the reason for calling
> one right after the other.
> 
> Signed-off-by: Yaakov Selkowitz <yselkowitz at users.sourceforge.net>
> ---
>  sys.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/sys.c b/sys.c
> index ba60fbf..cd8712e 100644
> --- a/sys.c
> +++ b/sys.c
> @@ -408,7 +408,17 @@ openTty(char *line)
>      int rc;
>      int tty = -1;
>  
> +#if !defined(O_NOCTTY) || !defined(TIOCSCTTY)
> +    /* e.g. Cygwin has a working O_NOCTTY but no TIOCSCTTY, so the tty
> +       never becomes controlling */
> +    tty = open(line, O_RDWR);
> +#else
> +    /* The TIOCSCTTY ioctl below will fail if the process already has a
> +       controlling tty (even if the current controlling tty is the same
> +       as the tty you want to make controlling).  So we need to open
> +       the tty with O_NOCTTY to make sure this doesn't happen. */
>      tty = open(line, O_RDWR | O_NOCTTY);
> +#endif
>   
>      if(tty < 0)
>          goto bail;

-- 
	-Alan Coopersmith-           alan.coopersmith at sun.com
	 Sun Microsystems, Inc. - X Window System Engineering



More information about the xorg-devel mailing list