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.28 by ayin, Tue Jun 26 21:29:30 2007 UTC vs.
Revision 1.33 by ayin, Thu Dec 13 14:42:33 2007 UTC

86 86
87 if (pfd >= 0) 87 if (pfd >= 0)
88 { 88 {
89 if (grantpt (pfd) == 0 /* change slave permissions */ 89 if (grantpt (pfd) == 0 /* change slave permissions */
90 && unlockpt (pfd) == 0) 90 && unlockpt (pfd) == 0)
91 {
91 { /* slave now unlocked */ 92 /* slave now unlocked */
92 *ttydev = strdup (ptsname (pfd)); /* get slave's name */ 93 *ttydev = strdup (ptsname (pfd)); /* get slave's name */
93 return pfd; 94 return pfd;
94 } 95 }
95 96
96 close (pfd); 97 close (pfd);
104 static int 105 static int
105 get_pty (int *fd_tty, char **ttydev) 106 get_pty (int *fd_tty, char **ttydev)
106 { 107 {
107 int pfd; 108 int pfd;
108 int res; 109 int res;
109 char tty_name[32];
110 110
111 res = openpty (&pfd, fd_tty, tty_name, NULL, NULL); 111 res = openpty (&pfd, fd_tty, NULL, NULL, NULL);
112 112
113 if (res != -1) 113 if (res != -1)
114 { 114 {
115 *ttydev = strdup (tty_name); 115 *ttydev = strdup (ttyname (*fd_tty));
116 return pfd; 116 return pfd;
117 } 117 }
118 118
119 return -1; 119 return -1;
120 } 120 }
123 123
124 static int 124 static int
125 get_pty (int *fd_tty, char **ttydev) 125 get_pty (int *fd_tty, char **ttydev)
126 { 126 {
127 int pfd; 127 int pfd;
128 char *slave;
128 129
129 *ttydev = _getpty (&pfd, O_RDWR | O_NONBLOCK | O_NOCTTY, 0622, 0); 130 slave = _getpty (&pfd, O_RDWR | O_NONBLOCK | O_NOCTTY, 0622, 0);
130 131
131 if (*ttydev != NULL) 132 if (slave != NULL)
133 {
134 *ttydev = strdup (slave);
132 return pfd; 135 return pfd;
136 }
133 137
134 return -1; 138 return -1;
135 } 139 }
136 140
137#elif defined(HAVE_DEV_PTC) 141#elif defined(HAVE_DEV_PTC)
323 { 327 {
324#ifdef TTY_GID_SUPPORT 328#ifdef TTY_GID_SUPPORT
325 struct group *gr = getgrnam ("tty"); 329 struct group *gr = getgrnam ("tty");
326 330
327 if (gr) 331 if (gr)
332 {
328 { /* change group ownership of tty to "tty" */ 333 /* change group ownership of tty to "tty" */
329 mode = S_IRUSR | S_IWUSR | S_IWGRP; 334 mode = S_IRUSR | S_IWUSR | S_IWGRP;
330 gid = gr->gr_gid; 335 gid = gr->gr_gid;
331 } 336 }
332 else 337 else
333#endif /* TTY_GID_SUPPORT */ 338#endif /* TTY_GID_SUPPORT */
334 { 339 {
335 mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; 340 mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH;
336 gid = 0; 341 gid = 0;
337 } 342 }
338 } 343 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines