PTYs with V.4

PTYs with V.4

Post by Ian G Batt » Sat, 26 Jan 1991 02:28:55



I'm trying to port a program which uses the BSD pty mechanism in a
fashion akin to telnet to V.4.  [[ The application is the ISODE 6.0 VT
daemon ]]

I get a master side by opening /dev/ptmx, call unlockpt on the result,
ptsname on the result and finally open the result of the ptsopen.
That's my slave.  Then I push (in order) ptem, ldterm and ttcompat
streams modules.

The call TIOCGETP then fails EINVAL.

Bearing in mind I know precious little about streams, can anyone suggest
if I've made an obvious * or if there are any places I would be
adviced to start looking for the problem?

Outline of the code:

        p = open ("/dev/ptmx", 2);
        cp = ptsname (p);
        unlockpt (p);
        t = open(cp, 2);
        if ((ioctl (t, I_PUSH, "ptem") < 0) ||
            (ioctl (t, I_PUSH, "ldterm") < 0) ||
            (ioctl (t, I_PUSH, "ttcompat") < 0))
          fatalperror (f, "stream push", errno);

        if (ioctl(t, TIOCGETP, (char*)&b) == -1) {
                perror("ioctl (TIOCGETP)");
                adios(NULLCP, "ioctl failed (TIOCGETP)");
        }  <== fails here

ian

 
 
 

PTYs with V.4

Post by Ian Donalds » Thu, 31 Jan 1991 12:18:18



Quote:>The call TIOCGETP then fails EINVAL.
>Outline of the code:
>    p = open ("/dev/ptmx", 2);
>    cp = ptsname (p);

        grantpt(p);                             <---- add this
Quote:>    unlockpt (p);
>    t = open(cp, 2);

        if(t == -1) {                           <---- add this
                perror(cp);                     <---- add this
                exit(1);                        <---- add this
        }                                       <---- add this

Quote:>    if ((ioctl (t, I_PUSH, "ptem") < 0) ||
>        (ioctl (t, I_PUSH, "ldterm") < 0) ||
>        (ioctl (t, I_PUSH, "ttcompat") < 0))
>      fatalperror (f, "stream push", errno);
>    if (ioctl(t, TIOCGETP, (char*)&b) == -1) {
>            perror("ioctl (TIOCGETP)");
>            adios(NULLCP, "ioctl failed (TIOCGETP)");
>    }  <== fails here

The program may have worked depending on the previous permissions of the
pty returned by ptsname().  On our system the mode before grantpt()
is called was 666 and so the program succeeded.  However, the mode may have
been anything, causing the 2nd open to fail.

For an example of streams-pty usage, look in the freely available X11R4 xterm
sources.

Ian D

 
 
 

1. PTY Limit/New PTY Creation

Subject: PTY Limit/New PTY Creation
Newsgroups: linux.dev.kernel
Summary:
Keywords:
X-Newsreader: TIN [version 1.2 PL2]

Subject: PTY Limit/New PTY Creation
Newsgroups: linux.dev.kernel
Summary:
Keywords:
X-Newsreader: TIN [version 1.2 PL2]

Can someone please point me to a development FAQ which discusses the
creation of the >64 PTYs allowed by 1.3.xx kernels?

We ran into an emergency "out of PTYs" problem on the ISP we run in Ft.
Lauderdale, and were forced to quickly move to a development kernel to
overcome this 'disaster.'  The 1.3.xx kernel we use is certainly able to
use more than 64 PTYs, but creating them was a different matter:

Using haste to fix a problem, I used a script called
'mkptys' included in a package designed to create PTYs for a patch
designed to patch 1.2.xx kernels with > 64 PTYs, but it created the PTYs
with the wrong Major number -- I hacked this script, and was able to create
the PTYs, which work, but now 'who' does not report everyone who is actually
online -- I suspect the medling I did with the PTYs to be the culprit.

Pointing me to a FAQ or even an archive of this group would be greatly
appreciated.

----------------------------------------------------------------------------
Scott G. Taylor                               |  LakerNet!
System Administrator/General Manager          |  Laker Information Systems
                                              |  Why Drive When You Can FLY?
1-954-359-3670 Ft. Lauderdale, Florida        |

10:30-5:00 Monday-Friday, 12:00-5:00 Saturday |  http://www.laker.net
----------------------------------------------------------------------------

2. Mozilla 0.9.9 port compile failure

3. pty handling

4. PATH_____help

5. expect problem: out of pty's

6. Booting problems on a PowerStack

7. MAKEDEV/KERNEL > 64 ptys

8. CPU vs Memory Cost/Effectiveness

9. Increasing pty without reboot

10. reading pty error stream

11. no ptys available

12. opening ptys - intermitant problem

13. How do I increase the number of pty's?