summaryrefslogtreecommitdiff
path: root/pty.c
diff options
context:
space:
mode:
Diffstat (limited to 'pty.c')
-rw-r--r--pty.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/pty.c b/pty.c
index e71bceb80..4b9370ce5 100644
--- a/pty.c
+++ b/pty.c
@@ -49,15 +49,19 @@ pty_allocate(int *ptyfd, int *ttyfd, char *namebuf, int namebuflen)
49{ 49{
50#if defined(HAVE_OPENPTY) || defined(BSD4_4) 50#if defined(HAVE_OPENPTY) || defined(BSD4_4)
51 /* openpty(3) exists in OSF/1 and some other os'es */ 51 /* openpty(3) exists in OSF/1 and some other os'es */
52 char buf[64]; 52 char *name;
53 int i; 53 int i;
54 54
55 i = openpty(ptyfd, ttyfd, buf, NULL, NULL); 55 i = openpty(ptyfd, ttyfd, NULL, NULL, NULL);
56 if (i < 0) { 56 if (i < 0) {
57 error("openpty: %.100s", strerror(errno)); 57 error("openpty: %.100s", strerror(errno));
58 return 0; 58 return 0;
59 } 59 }
60 strlcpy(namebuf, buf, namebuflen); /* possible truncation */ 60 name = ttyname(*ttyfd);
61 if (!name)
62 fatal("openpty returns device for which ttyname fails.");
63
64 strlcpy(namebuf, name, namebuflen); /* possible truncation */
61 return 1; 65 return 1;
62#else /* HAVE_OPENPTY */ 66#else /* HAVE_OPENPTY */
63#ifdef HAVE__GETPTY 67#ifdef HAVE__GETPTY