summaryrefslogtreecommitdiff
path: root/libutil
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2002-01-14 09:10:50 +0000
committerEric Andersen <andersen@codepoet.org>2002-01-14 09:10:50 +0000
commitad3d96f8b792149d4a623584f8b403d40bd60331 (patch)
treea642f520af5de3923c499f886e068e0b9bbdcef3 /libutil
parent50b14f6bf77048f65377f26fe8737b9bfb8512a1 (diff)
Patch from Brian Stafford <brian@stafford.uklinux.net> to fixup
support for Unix98 PTYs, and optionally exclude the older junk.
Diffstat (limited to 'libutil')
-rw-r--r--libutil/openpty.c20
1 files changed, 19 insertions, 1 deletions
diff --git a/libutil/openpty.c b/libutil/openpty.c
index 1c2adbf6a..f0574474b 100644
--- a/libutil/openpty.c
+++ b/libutil/openpty.c
@@ -32,6 +32,8 @@ extern int grantpt (int fd);
extern int ptsname_r (int fd, char *buf, size_t buflen);
extern int unlockpt (int fd);
+/* BCS: the following function is, IMO, overkill */
+#if 0
/* Return the result of ptsname_r in the buffer pointed to by PTS,
which should be of length BUF_LEN. If it is too long to fit in
this buffer, a sufficiently long buffer is allocated using malloc,
@@ -83,6 +85,7 @@ pts_name (int fd, char **pts, size_t buf_len)
return rv;
}
+#endif
/* Create pseudo tty master slave pair and set terminal attributes
according to TERMP and WINP. Return handles for both ends in
@@ -91,12 +94,20 @@ int
openpty (int *amaster, int *aslave, char *name, struct termios *termp,
struct winsize *winp)
{
+#if 0
#ifdef PATH_MAX
char _buf[PATH_MAX];
#else
char _buf[512];
#endif
char *buf = _buf;
+#else
+#ifdef PATH_MAX
+ char buf[PATH_MAX];
+#else
+ char buf[512];
+#endif
+#endif
int master, slave;
master = getpt ();
@@ -109,15 +120,20 @@ openpty (int *amaster, int *aslave, char *name, struct termios *termp,
if (unlockpt (master))
goto fail;
+#if 0
if (pts_name (master, &buf, sizeof (_buf)))
+#else
+ if (ptsname_r (master, buf, sizeof buf))
+#endif
goto fail;
slave = open (buf, O_RDWR | O_NOCTTY);
if (slave == -1)
{
+#if 0
if (buf != _buf)
free (buf);
-
+#endif
goto fail;
}
@@ -132,8 +148,10 @@ openpty (int *amaster, int *aslave, char *name, struct termios *termp,
if (name != NULL)
strcpy (name, buf);
+#if 0
if (buf != _buf)
free (buf);
+#endif
return 0;
fail: