pseudo-terminal master writes reappearing on the master side

pseudo-terminal master writes reappearing on the master side

Post by Rud Holmgr » Thu, 06 Feb 2003 17:27:43



I have a small problem with the linux pseudo terminals. As I
understand it, a user mode driver can open a master pty like
/dev/pty[x][n] and act as "terminal hardware" for applications
connection to /dev/tty[x][n]. The problem is that writes to
the pty reappears on the pty, as illustrated by the following
snippet of code:

void test_pty(void)
{
  int master_fd;
  char buffer[32];

  master_fd = open("/dev/ptys0", O_RDWR);

  write(master_fd, "foo", 3);
  read(master_fd, buffer, 3);

  buffer[3] = '\0';
  printf("%s\n", buffer);

Quote:}

Calling test_pty() produces "foo" on stdout. This is, for
my purposes, neither the desired nor the expected behaviour (writes
on the pty should only appear on the tty). Any suggestions??
 
 
 

pseudo-terminal master writes reappearing on the master side

Post by Kasper Dupon » Thu, 06 Feb 2003 19:13:46



> I have a small problem with the linux pseudo terminals. As I
> understand it, a user mode driver can open a master pty like
> /dev/pty[x][n] and act as "terminal hardware" for applications
> connection to /dev/tty[x][n]. The problem is that writes to
> the pty reappears on the pty, as illustrated by the following
> snippet of code:

> void test_pty(void)
> {
>   int master_fd;
>   char buffer[32];

>   master_fd = open("/dev/ptys0", O_RDWR);

>   write(master_fd, "foo", 3);
>   read(master_fd, buffer, 3);

>   buffer[3] = '\0';
>   printf("%s\n", buffer);
> }

> Calling test_pty() produces "foo" on stdout. This is, for
> my purposes, neither the desired nor the expected behaviour (writes
> on the pty should only appear on the tty). Any suggestions??

Probably this is caused by echoing being enabled. That can be
disabled by using an ioctl on the tty. Take a look on termios.

--
Kasper Dupont -- der bruger for meget tid p? usenet.

for(_=52;_;(_%5)||(_/=5),(_%5)&&(_-=2))putchar(_);

 
 
 

pseudo-terminal master writes reappearing on the master side

Post by Rud Holmgr » Fri, 07 Feb 2003 16:23:01




> > I have a small problem with the linux pseudo terminals. As I
> > understand it, a user mode driver can open a master pty like
> > /dev/pty[x][n] and act as "terminal hardware" for applications
> > connection to /dev/tty[x][n]. The problem is that writes to
> > the pty reappears on the pty, as illustrated by the following
> > snippet of code:

> > void test_pty(void)
> > {
> >   int master_fd;
> >   char buffer[32];

> >   master_fd = open("/dev/ptys0", O_RDWR);

> >   write(master_fd, "foo", 3);
> >   read(master_fd, buffer, 3);

> >   buffer[3] = '\0';
> >   printf("%s\n", buffer);
> > }

> > Calling test_pty() produces "foo" on stdout. This is, for
> > my purposes, neither the desired nor the expected behaviour (writes
> > on the pty should only appear on the tty). Any suggestions??

> Probably this is caused by echoing being enabled. That can be
> disabled by using an ioctl on the tty. Take a look on termios.

That was it - thanx!
 
 
 

1. doing tcgetattr on pseudo terminal masters on SVR4?

For some reason, I cannot do a tcgetattr() on a pseudo terminal master
that I've opened up.  I've done the grantpt() and unlockpt() as
specified in Advanced Programming in the Unix Environment by Stevens.
Unfortunately, the book does not give any examples of doing a
tcgetattr() on a pseudo terminal master.

I need to do this in my program in order to discover changes in the
stty state.

P.S. This is under Solaris 2.3.

2. HPUX question

3. HW compatibility of MSI 845E Master-LR / Master-LRM

4. problem with dip, netscape

5. Pseudo-master help

6. DIP terminates after I dial the number

7. Question on BSD Pseudo-TTY ioctl's (slave vs. master)

8. wu-ftpd.2.4 on linux compile error. ( dereferencing pointer to incomplete type)

9. Help : subshell.c : couldn't open master side of pty

10. writing to the master boot sector (track 0)

11. Master Boot Over Write

12. Can a pty master become a control terminal?

13. Need to get LILO to re-write to the Master Boot Record