From 507ff32f4ae1a62c28ddf7a9bfd7f82ff77d982e Mon Sep 17 00:00:00 2001 From: Petter Rodhelind Date: Mon, 6 Nov 2017 15:25:36 +0100 Subject: 9term: Fix ptys in MacOS High Sierra. --- src/cmd/9term/Darwin.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'src/cmd/9term/Darwin.c') diff --git a/src/cmd/9term/Darwin.c b/src/cmd/9term/Darwin.c index 0bd4ece7..369f7da2 100644 --- a/src/cmd/9term/Darwin.c +++ b/src/cmd/9term/Darwin.c @@ -2,16 +2,19 @@ #include "bsdpty.c" #undef getpts -#include - int getpts(int fd[], char *slave) { - if(openpty(&fd[1], &fd[0], NULL, NULL, NULL) >= 0){ - fchmod(fd[1], 0620); - strcpy(slave, ttyname(fd[0])); - return 0; - } - sysfatal("no ptys"); - return 0; + fd[1] = posix_openpt(ORDWR); + if (fd[1] >= 0) { + grantpt(fd[1]); + unlockpt(fd[1]); + fchmod(fd[1], 0620); + strcpy(slave, ptsname(fd[1])); + if ((fd[0] = open(slave, ORDWR)) >= 0) + return 0; + close(fd[1]); + } + sysfatal("no ptys"); + return 0; } -- cgit v1.2.3