This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: ttyname.c


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 <joel.sherrill@oarcorp.com>

* 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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]