From e2c57ad789285e99e1c9b75150065ecb134164c1 Mon Sep 17 00:00:00 2001 From: Pedro Falcato Date: Tue, 21 Feb 2023 23:22:11 +0000 Subject: [PATCH] Fix ttyname_r error return values POSIX specifies ttyname_r should return errno and not do the usual return errno = error, -1; Fixes #732 --- libc/unistd/ttyname_r.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libc/unistd/ttyname_r.c b/libc/unistd/ttyname_r.c index 8ae46737..768a6ca7 100644 --- a/libc/unistd/ttyname_r.c +++ b/libc/unistd/ttyname_r.c @@ -37,8 +37,8 @@ int ttyname_r(int fd, char* path, size_t path_size) name[3] = 'v'; name[4] = '/'; if ( ioctl(fd, TIOCGNAME, name + 5) < 0 ) - return -1; + return errno; if ( path_size <= strlcpy(path, name, path_size) ) - return errno = ERANGE, -1; + return ERANGE; return 0; }