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.30 by ayin, Thu Jun 28 17:46:18 2007 UTC vs.
Revision 1.34 by ayin, Fri Dec 14 09:51:32 2007 UTC

32#include <cstdlib> 32#include <cstdlib>
33#include <cstring> 33#include <cstring>
34#include <csignal> 34#include <csignal>
35 35
36#include <sys/types.h> 36#include <sys/types.h>
37#include <sys/stat.h>
37#include <unistd.h> 38#include <unistd.h>
38#include <fcntl.h> 39#include <fcntl.h>
39 40
40#ifdef HAVE_SYS_IOCTL_H 41#ifdef HAVE_SYS_IOCTL_H
41# include <sys/ioctl.h> 42# include <sys/ioctl.h>
86 87
87 if (pfd >= 0) 88 if (pfd >= 0)
88 { 89 {
89 if (grantpt (pfd) == 0 /* change slave permissions */ 90 if (grantpt (pfd) == 0 /* change slave permissions */
90 && unlockpt (pfd) == 0) 91 && unlockpt (pfd) == 0)
92 {
91 { /* slave now unlocked */ 93 /* slave now unlocked */
92 *ttydev = strdup (ptsname (pfd)); /* get slave's name */ 94 *ttydev = strdup (ptsname (pfd)); /* get slave's name */
93 return pfd; 95 return pfd;
94 } 96 }
95 97
96 close (pfd); 98 close (pfd);
126 int pfd; 128 int pfd;
127 char *slave; 129 char *slave;
128 130
129 slave = _getpty (&pfd, O_RDWR | O_NONBLOCK | O_NOCTTY, 0622, 0); 131 slave = _getpty (&pfd, O_RDWR | O_NONBLOCK | O_NOCTTY, 0622, 0);
130 132
131 if (slave != NULL) { 133 if (slave != NULL)
134 {
132 *ttydev = strdup (slave); 135 *ttydev = strdup (slave);
133 return pfd; 136 return pfd;
134 } 137 }
135 138
136 return -1; 139 return -1;
137 } 140 }
138 141
139#elif defined(HAVE_DEV_PTC) 142#elif defined(HAVE_DEV_PTC)
325 { 328 {
326#ifdef TTY_GID_SUPPORT 329#ifdef TTY_GID_SUPPORT
327 struct group *gr = getgrnam ("tty"); 330 struct group *gr = getgrnam ("tty");
328 331
329 if (gr) 332 if (gr)
333 {
330 { /* change group ownership of tty to "tty" */ 334 /* change group ownership of tty to "tty" */
331 mode = S_IRUSR | S_IWUSR | S_IWGRP; 335 mode = S_IRUSR | S_IWUSR | S_IWGRP;
332 gid = gr->gr_gid; 336 gid = gr->gr_gid;
333 } 337 }
334 else 338 else
335#endif /* TTY_GID_SUPPORT */ 339#endif /* TTY_GID_SUPPORT */
336 { 340 {
337 mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH; 341 mode = S_IRUSR | S_IWUSR | S_IWGRP | S_IWOTH;
338 gid = 0; 342 gid = 0;
339 } 343 }
340 } 344 }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines