~ubuntu-branches/ubuntu/karmic/rxvt-unicode/karmic

« back to all changes in this revision

Viewing changes to src/ptytty.C

  • Committer: Bazaar Package Importer
  • Author(s): Decklin Foster
  • Date: 2007-08-03 12:44:44 UTC
  • mfrom: (1.1.10 upstream)
  • Revision ID: james.westby@ubuntu.com-20070803124444-uwmus5csvd7rm4fp
Tags: 8.3-1
* New upstream release (Closes: #433004)
  - Rolled with autoconf 2.61 (Closes: #422540)
* Match https URLs in selection-popup (Closes: #428659)
* Fix typos in urxvtperl(3) (Closes: #411074, #415848)
* Use sensible-browser instead of x-www-browser directly (Closes: #415846)
* Added urxvtcd as alternative (Closes: #381967)

Show diffs side-by-side

added added

removed removed

Lines of Context:
65
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
69
 * If successful, ttydev is set to the name of the slave device.
70
70
 * fd_tty _may_ also be set to an open fd to the slave device
71
71
 */
106
106
  {
107
107
    int pfd;
108
108
    int res;
109
 
    char tty_name[32];
110
 
    
111
 
    res = openpty (&pfd, fd_tty, tty_name, NULL, NULL);
 
109
 
 
110
    res = openpty (&pfd, fd_tty, NULL, NULL, NULL);
112
111
 
113
112
    if (res != -1)
114
113
      {
115
 
        *ttydev = strdup (tty_name);
 
114
        *ttydev = strdup (ttyname (*fd_tty));
116
115
        return pfd;
117
116
      }
118
117
 
125
124
  get_pty (int *fd_tty, char **ttydev)
126
125
  {
127
126
    int pfd;
128
 
 
129
 
    *ttydev = _getpty (&pfd, O_RDWR | O_NONBLOCK | O_NOCTTY, 0622, 0);
130
 
 
131
 
    if (*ttydev != NULL)
 
127
    char *slave;
 
128
 
 
129
    slave = _getpty (&pfd, O_RDWR | O_NONBLOCK | O_NOCTTY, 0622, 0);
 
130
 
 
131
    if (slave != NULL) {
 
132
      *ttydev = strdup (slave);
132
133
      return pfd;
 
134
    }
133
135
 
134
136
    return -1;
135
137
  }
208
210
 
209
211
/*----------------------------------------------------------------------*/
210
212
/*
211
 
 * Returns tty file descriptor, or -1 on failure 
 
213
 * Returns tty file descriptor, or -1 on failure
212
214
 */
213
215
static int
214
216
get_tty (char *ttydev)
223
225
static int
224
226
control_tty (int fd_tty)
225
227
{
 
228
  int fd;
 
229
 
226
230
  setsid ();
227
231
 
228
232
#if defined(HAVE_DEV_PTMX) && defined(I_PUSH)
253
257
    }
254
258
#endif
255
259
 
 
260
#ifdef TIOCSCTTY
256
261
  ioctl (fd_tty, TIOCSCTTY, NULL);
 
262
#else
 
263
  fd = open (ttyname (fd_tty), O_RDWR);
 
264
  if (fd >= 0)
 
265
    close (fd);
 
266
#endif
257
267
 
258
 
  int fd = open ("/dev/tty", O_WRONLY);
 
268
  fd = open ("/dev/tty", O_WRONLY);
259
269
  if (fd < 0)
260
270
    return -1; /* fatal */
261
271