diff options
-rw-r--r-- | contrib/netbsd-tests/lib/libc/gen/t_ttyname.c | 3 | ||||
-rw-r--r-- | lib/libc/gen/ttyname.c | 4 |
2 files changed, 2 insertions, 5 deletions
diff --git a/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c b/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c index bb9d264..0c10c24 100644 --- a/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c +++ b/contrib/netbsd-tests/lib/libc/gen/t_ttyname.c @@ -107,9 +107,6 @@ ATF_TC_BODY(ttyname_r_err, tc) ATF_REQUIRE(rv == ERANGE); } -#ifdef __FreeBSD__ - atf_tc_expect_fail("FreeBSD returns ENOTTY instead of EBADF; see bin/191936"); -#endif rv = ttyname_r(-1, buf, ttymax); ATF_REQUIRE(rv == EBADF); diff --git a/lib/libc/gen/ttyname.c b/lib/libc/gen/ttyname.c index a21b77f..02aa158 100644 --- a/lib/libc/gen/ttyname.c +++ b/lib/libc/gen/ttyname.c @@ -65,7 +65,7 @@ ttyname_r(int fd, char *buf, size_t len) /* Must be a terminal. */ if (!isatty(fd)) - return (ENOTTY); + return (errno); /* Must have enough room */ if (len <= sizeof(_PATH_DEV)) return (ERANGE); @@ -73,7 +73,7 @@ ttyname_r(int fd, char *buf, size_t len) strcpy(buf, _PATH_DEV); used = strlen(buf); if (fdevname_r(fd, buf + used, len - used) == NULL) - return (ENOTTY); + return (errno == EINVAL ? ERANGE : errno); return (0); } |