On Wed, 12 Apr 2000, Derek Martin <[EMAIL PROTECTED]> wrote:
> On Wed, 12 Apr 2000, Mike Bilow wrote:
> 
> > My guess is that your source code does not understand UNIX98 devpts.
> 
> Speaking of which, can someone explain briefly how to make use of these?
> >From what I gather, you allocate yourself a pty by opening /dev/ptmx with
> a call something like this:
> 
>   fd = open("/dev/ptmx", O_RDWR);
> 
> and then you can determine the pty that was supposedly allocated to you
> using ioctl, a la:
> 
>   ioctl( fd, TIOCGPTN, (char *) &pty);
> 
> (I'm going from memory, so if either that macro or the call itself is
> wrong... whatever).
> 
> This apparently does indeed place the number of the next available pty
> into the int variable pty (i.e. /dev/pts/8 as in one case where I tried
> it).
> 
> So my question is, now what?  If I do an lsof and grep on that process, I
> see my controlling tty, and I see /dev/ptmx is open, but I don't see
> /dev/pts/8 listed as open.  Do I now need to explicitly open this pty and
> get a seperate file descriptor?

I believe so, in general you have to next open up the corresponding
"slave" pty (and perhaps connect this slave to the stdio of an external
program, e.g. ssh or ftp, via fork and exec).

Mind you, I haven't used the new /dev/ptmx mechanism except perhaps
running some tutorial examples. However, I believe the new mechanism
only really effects the first open: it cleans up the silly looping over
all (A,B) trying to open a master /dev/ptyAB until it succeeds (and then
doing a 2nd open on the corresponding slave: /dev/ttyAB). This pushes the
first step to the kernel where it belongs, but the second step is
changed little if at all.

Hope this helps (and is correct!)


Karl Runge


**********************************************************
To unsubscribe from this list, send mail to
[EMAIL PROTECTED] with the following text in the
*body* (*not* the subject line) of the letter:
unsubscribe gnhlug
**********************************************************

Reply via email to