diff options
Diffstat (limited to 'pty.c')
-rw-r--r-- | pty.c | 10 |
1 files changed, 7 insertions, 3 deletions
@@ -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 |