Use openpty() to deal with the new pty naming scheme.
This commit is contained in:
parent
5004b7788d
commit
688f49ac00
|
@ -1,4 +1,4 @@
|
||||||
# $NetBSD: Makefile,v 1.8 1997/11/21 08:35:41 lukem Exp $
|
# $NetBSD: Makefile,v 1.9 2002/05/30 03:22:58 simonb Exp $
|
||||||
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
# @(#)Makefile 8.1 (Berkeley) 6/6/93
|
||||||
|
|
||||||
PROG= window
|
PROG= window
|
||||||
|
@ -16,7 +16,7 @@ SRCS= char.c cmd.c cmd1.c cmd2.c cmd3.c cmd4.c cmd5.c cmd6.c cmd7.c \
|
||||||
wwterminfo.c wwtty.c wwunframe.c wwupdate.c wwwrite.c xx.c xxflush.c \
|
wwterminfo.c wwtty.c wwunframe.c wwupdate.c wwwrite.c xx.c xxflush.c \
|
||||||
compress.c
|
compress.c
|
||||||
MAN= window.1
|
MAN= window.1
|
||||||
DPADD= ${LIBTERMCAP}
|
DPADD= ${LIBTERMCAP} ${LIBUTIL}
|
||||||
LDADD= -ltermcap
|
LDADD= -ltermcap -lutil
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
.include <bsd.prog.mk>
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
/* $NetBSD: wwpty.c,v 1.5 1997/11/21 08:49:12 mrg Exp $ */
|
/* $NetBSD: wwpty.c,v 1.6 2002/05/30 03:22:58 simonb Exp $ */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Copyright (c) 1983, 1993
|
* Copyright (c) 1983, 1993
|
||||||
|
@ -41,7 +41,7 @@
|
||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)wwpty.c 8.1 (Berkeley) 6/6/93";
|
static char sccsid[] = "@(#)wwpty.c 8.1 (Berkeley) 6/6/93";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: wwpty.c,v 1.5 1997/11/21 08:49:12 mrg Exp $");
|
__RCSID("$NetBSD: wwpty.c,v 1.6 2002/05/30 03:22:58 simonb Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
|
@ -49,49 +49,24 @@ __RCSID("$NetBSD: wwpty.c,v 1.5 1997/11/21 08:49:12 mrg Exp $");
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#endif
|
#endif
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <string.h>
|
#include <util.h>
|
||||||
#include <unistd.h>
|
|
||||||
#include "ww.h"
|
#include "ww.h"
|
||||||
|
|
||||||
int
|
int
|
||||||
wwgetpty(w)
|
wwgetpty(w)
|
||||||
struct ww *w;
|
struct ww *w;
|
||||||
{
|
{
|
||||||
char c, *p;
|
|
||||||
int tty;
|
|
||||||
int on = 1;
|
int on = 1;
|
||||||
#define PTY "/dev/XtyXX"
|
int result, tty;
|
||||||
#define _PT 5
|
|
||||||
#define _PQRS 8
|
|
||||||
#define _0_9 9
|
|
||||||
|
|
||||||
(void) strcpy(w->ww_ttyname, PTY);
|
result = openpty(&w->ww_pty, &tty, w->ww_ttyname, NULL, NULL);
|
||||||
for (c = 'p'; c <= 'u'; c++) {
|
if (result < 0) {
|
||||||
w->ww_ttyname[_PT] = 'p';
|
w->ww_pty = -1;
|
||||||
w->ww_ttyname[_PQRS] = c;
|
wwerrno = WWE_NOPTY;
|
||||||
w->ww_ttyname[_0_9] = '0';
|
return -1;
|
||||||
if (access(w->ww_ttyname, 0) < 0)
|
} else {
|
||||||
break;
|
(void) ioctl(w->ww_pty, TIOCPKT, (char *)&on);
|
||||||
for (p = "0123456789abcdef"; *p; p++) {
|
(void) fcntl(w->ww_pty, F_SETFD, 1);
|
||||||
w->ww_ttyname[_PT] = 'p';
|
return 0;
|
||||||
w->ww_ttyname[_0_9] = *p;
|
|
||||||
if ((w->ww_pty = open(w->ww_ttyname, 2)) < 0)
|
|
||||||
continue;
|
|
||||||
w->ww_ttyname[_PT] = 't';
|
|
||||||
if ((tty = open(w->ww_ttyname, 2)) < 0) {
|
|
||||||
(void) close(w->ww_pty);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
(void) close(tty);
|
|
||||||
if (ioctl(w->ww_pty, TIOCPKT, (char *)&on) < 0) {
|
|
||||||
(void) close(w->ww_pty);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
(void) fcntl(w->ww_pty, F_SETFD, 1);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
w->ww_pty = -1;
|
|
||||||
wwerrno = WWE_NOPTY;
|
|
||||||
return -1;
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue