… | |
… | |
63 | |
63 | |
64 | /* ------------------------------------------------------------------------- * |
64 | /* ------------------------------------------------------------------------- * |
65 | * GET PSEUDO TELETYPE - MASTER AND SLAVE * |
65 | * GET PSEUDO TELETYPE - MASTER AND SLAVE * |
66 | * ------------------------------------------------------------------------- */ |
66 | * ------------------------------------------------------------------------- */ |
67 | /* |
67 | /* |
68 | * Returns pty file descriptor, or -1 on failure |
68 | * Returns pty file descriptor, or -1 on failure |
69 | * If successful, ttydev is set to the name of the slave device. |
69 | * If successful, ttydev is set to the name of the slave device. |
70 | * fd_tty _may_ also be set to an open fd to the slave device |
70 | * fd_tty _may_ also be set to an open fd to the slave device |
71 | */ |
71 | */ |
72 | #if defined(UNIX98_PTY) |
72 | #if defined(UNIX98_PTY) |
73 | |
73 | |
… | |
… | |
105 | get_pty (int *fd_tty, char **ttydev) |
105 | get_pty (int *fd_tty, char **ttydev) |
106 | { |
106 | { |
107 | int pfd; |
107 | int pfd; |
108 | int res; |
108 | int res; |
109 | char tty_name[32]; |
109 | char tty_name[32]; |
110 | |
110 | |
111 | res = openpty (&pfd, fd_tty, tty_name, NULL, NULL); |
111 | res = openpty (&pfd, fd_tty, tty_name, NULL, NULL); |
112 | |
112 | |
113 | if (res != -1) |
113 | if (res != -1) |
114 | { |
114 | { |
115 | *ttydev = strdup (tty_name); |
115 | *ttydev = strdup (tty_name); |
… | |
… | |
206 | |
206 | |
207 | #endif |
207 | #endif |
208 | |
208 | |
209 | /*----------------------------------------------------------------------*/ |
209 | /*----------------------------------------------------------------------*/ |
210 | /* |
210 | /* |
211 | * Returns tty file descriptor, or -1 on failure |
211 | * Returns tty file descriptor, or -1 on failure |
212 | */ |
212 | */ |
213 | static int |
213 | static int |
214 | get_tty (char *ttydev) |
214 | get_tty (char *ttydev) |
215 | { |
215 | { |
216 | return open (ttydev, O_RDWR | O_NOCTTY, 0); |
216 | return open (ttydev, O_RDWR | O_NOCTTY, 0); |
… | |
… | |
251 | ioctl (fd_tty, I_PUSH, "ldterm"); |
251 | ioctl (fd_tty, I_PUSH, "ldterm"); |
252 | ioctl (fd_tty, I_PUSH, "ttcompat"); |
252 | ioctl (fd_tty, I_PUSH, "ttcompat"); |
253 | } |
253 | } |
254 | #endif |
254 | #endif |
255 | |
255 | |
|
|
256 | #ifdef TIOCSCTTY |
256 | ioctl (fd_tty, TIOCSCTTY, NULL); |
257 | ioctl (fd_tty, TIOCSCTTY, NULL); |
|
|
258 | #else |
|
|
259 | fd = open (name, O_RDWR); |
|
|
260 | if (fd >= 0) |
|
|
261 | close (fd); |
|
|
262 | #endif |
257 | |
263 | |
258 | int fd = open ("/dev/tty", O_WRONLY); |
264 | int fd = open ("/dev/tty", O_WRONLY); |
259 | if (fd < 0) |
265 | if (fd < 0) |
260 | return -1; /* fatal */ |
266 | return -1; /* fatal */ |
261 | |
267 | |