Fix ttyname_r error return values

POSIX specifies ttyname_r should return errno and not do the usual
return errno = error, -1;

Fixes #732
This commit is contained in:
Pedro Falcato 2023-02-21 23:22:11 +00:00
parent 4379ca962a
commit e2c57ad789
1 changed files with 2 additions and 2 deletions

View File

@ -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;
}