diff options
author | jilles <jilles@FreeBSD.org> | 2015-02-01 22:50:33 +0000 |
---|---|---|
committer | jilles <jilles@FreeBSD.org> | 2015-02-01 22:50:33 +0000 |
commit | 6bc8b6eb4c7154f6740245cb0b45f9bc2e04945f (patch) | |
tree | 49d4b6577a32bf1e3072d98add9eb1f6af243043 /lib/libc/gen/ttyname.c | |
parent | 8adb86862b914637b98b57e7708b6d2171e108e1 (diff) | |
download | FreeBSD-src-6bc8b6eb4c7154f6740245cb0b45f9bc2e04945f.zip FreeBSD-src-6bc8b6eb4c7154f6740245cb0b45f9bc2e04945f.tar.gz |
ttyname_r(): Return actual error, not always [ENOTTY].
Adjust the test that used to fail because of this bug.
PR: 191936
MFC after: 1 week
Diffstat (limited to 'lib/libc/gen/ttyname.c')
-rw-r--r-- | lib/libc/gen/ttyname.c | 4 |
1 files changed, 2 insertions, 2 deletions
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); } |