From 4c593181389b86bc184bdbf2b09dfdadd57b9c71 Mon Sep 17 00:00:00 2001 From: Eric Andersen Date: Tue, 22 Oct 2002 07:13:57 +0000 Subject: When UNIX98PTY_ONLY was false, but Unix 98 ptys were in fact working and functional, everything would succeed but then we would return a failure due to a silly logic bug. This patch fixes it so things will work correctly regardless of the UNIX98PTY_ONLY setting. -Erik --- libc/stdlib/ptsname.c | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) (limited to 'libc/stdlib') diff --git a/libc/stdlib/ptsname.c b/libc/stdlib/ptsname.c index 74f3e87d9..7f9b04e93 100644 --- a/libc/stdlib/ptsname.c +++ b/libc/stdlib/ptsname.c @@ -102,6 +102,15 @@ int ptsname_r (int fd, char *buf, size_t buflen) strcpy (buf, devpts); strcat (buf, p); + /* Note: Don't bother with stat on the slave name and checking the + driver's major device number - the ioctl above succeeded so + we know the fd was a Unix'98 master and the /dev/pts/ prefix + is set by definition. If the name isn't really a slave PTY, + the system is misconfigured anyway - something else will fail + later. + */ + errno = save_errno; + return 0; } #endif #if defined UNIX98PTY_ONLY @@ -111,13 +120,6 @@ int ptsname_r (int fd, char *buf, size_t buflen) errno = ENOTTY; return ENOTTY; } - /* Note: Don't bother with stat on the slave name and checking the - driver's major device number - the ioctl above succeeded so - we know the fd was a Unix'98 master and the /dev/pts/ prefix - is set by definition. If the name isn't really a slave PTY, - the system is misconfigured anyway - something else will fail - later. - */ #else # if !defined TIOCGPTN else if (errno == EINVAL) -- cgit v1.2.3