diff options
Diffstat (limited to 'libc/unistd/ptsname_r.c')
| -rw-r--r-- | libc/unistd/ptsname_r.c | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/libc/unistd/ptsname_r.c b/libc/unistd/ptsname_r.c index 1ed067b..2fa4c3d 100644 --- a/libc/unistd/ptsname_r.c +++ b/libc/unistd/ptsname_r.c @@ -32,7 +32,7 @@ #include <errno.h> #include <string.h> -char* ptsname_r( int fd, char* buf, size_t buflen) +int ptsname_r( int fd, char* buf, size_t buflen) { unsigned int pty_num; char buff[64]; @@ -40,17 +40,19 @@ char* ptsname_r( int fd, char* buf, size_t buflen) if (buf == NULL) { errno = EINVAL; - return NULL; + return -1; } - if ( ioctl( fd, TIOCGPTN, &pty_num ) != 0 ) - return NULL; + if ( ioctl( fd, TIOCGPTN, &pty_num ) != 0 ) { + errno = ENOTTY; + return -1; + } len = snprintf( buff, sizeof(buff), "/dev/pts/%u", pty_num ); if (len+1 > (int)buflen) { errno = ERANGE; - return NULL; + return -1; } memcpy( buf, buff, len+1 ); - return buf; + return 0; } |
