Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 27 Jul 2000 16:36:11 -0400 (EDT)
From:      Luoqi Chen <luoqi@watermarkgroup.com>
To:        bde@zeta.org.au, brdean@unx.sas.com
Cc:        freebsd-arch@FreeBSD.ORG
Subject:   Re: isatty() reports false results
Message-ID:  <200007272036.e6RKaBR18831@lor.watermarkgroup.com>

next in thread | raw e-mail | index | archive | help
> On Thu, 27 Jul 2000, Bruce Evans wrote:
> 
> > Probably not.  POSIX.1 says that tcgetattr() shall return EBADF for non-
> > open files and ENOTTY for non-terminals.  These are the only errors
> > mentioned in POSIX.1.  Returning EAGAIN is probably a bug.  OTOH, checking
> > for only EAGAIN is a bug if there are any other undocumented error returns.
> 
> It looks like this behaviour of the pty ioctl() was introduced a
> little over a year ago in revision 1.58 of kern/tty_pty.c.  The commit
> log (by luoqi) only says "Ignore some ioctls on the master until the
> slave is open."  The commit log does not make clear any other reason
> regarding what was trying to be solved by this change.  Can anyone
> (Luoqi?) elaborate on the reasons?  Maybe we can solve the problem in
> another way that allows us to conform to the POSIX return codes that
> Bruce refers to above.
> 
IIRC, TIOCSET* ioctls on a master without the slave being open would
cause a panic. In the initial fix I committed (rev 1.58), I returned
success for these ioctls without doing anything. But later I changed
to return an error code (EAGAIN) at Bruce's suggestion.

> I looked at my NetBSD box and they do not short circuit these
> ioctl()'s in this case.  They must be handling this in another way,
> though I have not had a chance to dig into their code further.  I do
> note that when I modified my local kernel to defeat this change, my
> system paniced pretty quickly when I attempt an incoming telnet
> connection which uses the ptys.  And this is primarily why I was
> looking at modifying 'isatty()' to be smarter instead of messing
> around in the pty driver.
> 
> I suppose, at worst, we could move the TIOCGETA handling to precede
> the check for the slave being open.  Would that be valid?
> 
The master is not in the normal sense a tty, I think we could just change
the return code from EAGAIN to ENOTTY to conform to the POSIX standard.
As for isatty(), I don't think we need to change anything, it is a pilot
error to call isatty() on the master side of the pty.

> -Brian
> 

-lq


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-arch" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200007272036.e6RKaBR18831>