Jeff Johnston
Wed Nov 19 10:41:00 GMT 2008

Joel Sherrill wrote:
> Hi,
> With RTEMS, we build newlib before the OS.  We do not have
> access to termios yet.  So the new ttyname.c does not compile
> for RTEMS inside newlib.   Would it be OK to use isatty()
> instead of this?
>  /* Must be a terminal. */
>  if (tcgetattr (fd, &tty) < 0)
>    return errno;       /* Can be EBADF or ENOTTY */
> newlib already assumes isatty() exists.
> Attached is a patch.
> 2008-11-18  Joel Sherrill <>
>    * libc/unix/ttyname.c: Use isatty() instead of tcgetattr().

Ok.  Patch checked in after fixing comment.  IMO, setting the return 
value directly to ENOTTY as
you did is preferable to using errno since there is no guarantee a 
platform using newlib will do
so properly in isatty (i.e. it could leave errno unset and we would 
return success).

-- Jeff J.

More information about the Newlib mailing list