ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libptytty/src/ptytty.C
(Generate patch)

Comparing libptytty/src/ptytty.C (file contents):
Revision 1.27 by ayin, Mon Jun 25 17:22:40 2007 UTC vs.
Revision 1.29 by ayin, Thu Jun 28 17:41:01 2007 UTC

104 static int 104 static int
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];
110 109
111 res = openpty (&pfd, fd_tty, tty_name, NULL, NULL); 110 res = openpty (&pfd, fd_tty, NULL, NULL, NULL);
112 111
113 if (res != -1) 112 if (res != -1)
114 { 113 {
115 *ttydev = strdup (tty_name); 114 *ttydev = strdup (ttyname (*fd_tty));
116 return pfd; 115 return pfd;
117 } 116 }
118 117
119 return -1; 118 return -1;
120 } 119 }
221 * Make our tty a controlling tty so that /dev/tty points to us 220 * Make our tty a controlling tty so that /dev/tty points to us
222 */ 221 */
223static int 222static int
224control_tty (int fd_tty) 223control_tty (int fd_tty)
225{ 224{
225 int fd;
226
226 setsid (); 227 setsid ();
227 228
228#if defined(HAVE_DEV_PTMX) && defined(I_PUSH) 229#if defined(HAVE_DEV_PTMX) && defined(I_PUSH)
229 /* 230 /*
230 * Push STREAMS modules: 231 * Push STREAMS modules:
254#endif 255#endif
255 256
256#ifdef TIOCSCTTY 257#ifdef TIOCSCTTY
257 ioctl (fd_tty, TIOCSCTTY, NULL); 258 ioctl (fd_tty, TIOCSCTTY, NULL);
258#else 259#else
259 fd = open (name, O_RDWR); 260 fd = open (ttyname (fd_tty), O_RDWR);
260 if (fd >= 0) 261 if (fd >= 0)
261 close (fd); 262 close (fd);
262#endif 263#endif
263 264
264 int fd = open ("/dev/tty", O_WRONLY); 265 fd = open ("/dev/tty", O_WRONLY);
265 if (fd < 0) 266 if (fd < 0)
266 return -1; /* fatal */ 267 return -1; /* fatal */
267 268
268 close (fd); 269 close (fd);
269 270

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines