Opened 3 years ago

Last modified 3 years ago

#118 new defect

libc: isatty(3) is POSIX-nonconformant

Reported by: Lukáš Zaoral Owned by:
Priority: major Milestone: 4.5
Component: DiOS Keywords:
Cc: kdudka@…, lzaoral@…

Description

The current implementation of isatty(3) in DiOS returns EINVAL if fd is a valid file descriptor (assuming that __libc_fstat behaves as fstat(2)) or returns 0 if it is not.

This contradicts the POSIX manual page as the only valid return values are 1 or 0 with set errno.

Change History (1)

comment:1 Changed 3 years ago by Lukáš Zaoral

Sorry for the confusion, I've misunderstood the piece of code. The actual behaviour of DiOS' isatty(3) is hopefully the following:

  • if fd IS a valid file descriptor, EINVAL is returned (which is a positive integer),
  • if fd IS NOT a valid file descriptor, fstat's -1 is returned and EBADF is set by the fstat call.

assuming that __libc_fstat behaves as fstat(2). This is, however, still a violation of the POSIX standard that can make some parts of the program falsely unreachable by Divine (mainly if there is a comparison of the return value for equality with zero).

Note: See TracTickets for help on using tickets.