Post Go back to editing

2008-02-04 10:21:12     /dev/ptmx - wrong

2008-02-04 10:21:12     /dev/ptmx - wrong

Duane Ellis (UNITED STATES)

Message: 50631   

The "/dev/ptmx" feature is (pseudo terminals) has a problem.

In the end, the function ptsname() returns a device name that does not exist.

For example if the PTY is 7, it should return /dev/pts/7 -which it does

The device /dev/pts/7 (with the slash) does not exist.

The device /dev/pts7 {without the slash} does exist.

The work around is: muck with the filename returned by ptsname()

Works just fine on x86-linux, but wrong on blackfin-uclinux.

#include <stdio.h>

#include <stdlib.h>

#include <errno.h>

#include <string.h>

#include <fcntl.h>

int

main( int argc, char **argv )

{

char *cp;

int h;

h = open( "/dev/ptmx", O_RDWR | O_NOCTTY | O_NONBLOCK );

if( h < 0 ){

  printf("Cannot open PTMX, error: %d %s\n", errno, strerror(errno));

  exit(1);

}

cp = ptsname(h);

printf("PTMX Name is: %s\n", cp);

for(;;)

  ;

}

-Duane.

QuoteReplyEditDelete

2008-02-04 12:15:01     Re: /dev/ptmx - wrong

Robin Getz (UNITED STATES)

Message: 50636    Duane:

On the target:

root:~> cat /proc/filesystems | grep pts

nodev   devpts

root:~> mount | grep pts

devpts on /dev/pts type devpts (rw)

When I have telnet into the board (activate a pseudo terminal)

root:~> ls -l /dev/pts/*

crw-------    1 root     root     136,   0 Aug  6 11:53 /dev/pts/0

root:~> find /dev/ -name "pt*"

/dev/ptmx

/dev/pts

When I run your application (on the target)

root:~> /var/a.out

PTMX Name is: /dev/pts/1

Can you double check that devpts is mounted properly?

-Robin

QuoteReplyEditDelete

2008-02-04 13:30:37     Re: /dev/ptmx - wrong

Duane Ellis (UNITED STATES)

Message: 50643   

>> root:~> mount | grep pts

>> devpts on /dev/pts type devpts (rw)

That seems to make a difference. I did not have it mounted.

I'll have to test my other combinations to see if it is completely fixed.

-Duane.

QuoteReplyEditDelete

2008-02-04 23:40:16     Re: /dev/ptmx - wrong

Mike Frysinger (UNITED STATES)

Message: 50665    if you want to use Unix98 PTY's, you need to have devpts mounted on /dev/pts/ as the kernel will automatically manage it with device nodes as the masters/slaves are created/destroyed