[11451] in Athena Bugs

home help back first fref pref prev next nref lref last post

sun4 7.6P: codecenter

daemon@ATHENA.MIT.EDU (alexp@MIT.EDU)
Tue Nov 30 15:12:48 1993

From: alexp@MIT.EDU
Date: Tue, 30 Nov 93 15:12:31 EST
To: Calvin Clark <ckclark@MIT.EDU>, bugs@MIT.EDU
Cc: alexp@MIT.EDU


Calvin,

I have received the further information below from Centerline in response to
your bug report about the error:

>Can't open /dev/pts/3: Device busy
>Failed to set /dev/pts/3 as our controlling tty!

Please let me know if this solves your problem. 

Please also let me know if your other bug ("can't recognize 'const'") has been
resolved so I can close it out. Thanks,

                                          Alex

        ================Document 87.421====================
 
The message:
        can't find pty for interactive workspace
 
occurs when *Center is unable to allocate a pseudo-tty for use as
the RunWindow.  This can occur for several reasons:
 
1: This can occurs when the users on the machine 
have used up all of the available ptys. For this to happen under 
normal circumstances there would be many users logged into the 
machine with many "ttys" (windows) up, around 50 on a SPARC.
 
2: The user does not have write permission on the tty. The permissions
should look like this,
 
crw-rw-rw-  1 root      20,  40 Apr  8  1991 /dev/ttyr8
 
3: In extreme cases, this error can be caused by not having enough
virtual memory.  In the case we saw, the user had less swap space
than physical memory (on a Solaris 2 machine).
 
4: In cases where a process has child processes which fail to exit
properly, the pty maybe left reserved.
 
A "ps" will tell you which processes are attached to which pty's:
 
        ps aux
 
on BSD (SunOS 4) and
 
        ps -aef
 
on SysV (Solaris, HP, Motorola) machines.  It's a good way to find the
renegade processes which have swiped pty's.
 
If none of the above reasons seem to apply, see doc #151.179 for a program 
which finds and identifies orphan ptys.  The pty allocation mimics that
of *Center -- and may give more information about why the pty allocation
is failing. The find_orphan program only works on non-Solaris machines; 
the Solaris 2 version of our products allocations pseudo-ttys differently.
Below is a program that will print out why the user is unable to allocate
a pty under Solaris 2:

/* pty.c:  This is used for Solaris 2 machines.  It prints out diagnostics
   explaining why it can't allocate a pty.  */
#include <stdio.h>
#include <sys/fcntl.h>
#include <errno.h>
 
#include <stropts.h>
#include <unistd.h>
 
main()
{
    int         masterfd;
    int         slavefd;
    char        *snamep;
 
    /* System V.4 target allocates ptys by first opening the pseudo-terminal
     * master clone device "/dev/ptmx".  You must then make several
     * system calls to configure and control the behavior of the slave 
     * pty.
     */
    if ((masterfd = open("/dev/ptmx", O_RDWR)) < 0)
        {
        printf("Couldn't open /dev/ptmx: %d\n", errno);
        exit(-1);
        }
    if (grantpt(masterfd) < 0){         /* grant access to slave pty device */
        close(masterfd);
        printf("grantpt failed\n");
        exit(-1);
    }
    if (unlockpt(masterfd) < 0){        /* unlock a pty master/slave pair */
        close(masterfd);
        printf("unlockpt failed\n");
        exit(-1);
    }
    if ((snamep = (char *)ptsname(masterfd)) == NULL){
        close(masterfd);                /* get name of the slave ptr device */
        printf("ptsname failed\n");
        exit(-1);
    }
    if ((slavefd = open(snamep, O_RDWR)) < 0){
        printf("Couldn't open slave: %d\n", errno);
        close(masterfd);                /* open slave side of pty */
        exit(-1);
    }
    if (ioctl (slavefd, I_PUSH, "ptem") < 0)    /* pty hardware emul module */
        {
        printf("1st ioctl failed: %d\n", errno);
        close(masterfd);
        close(slavefd);
        exit(-1);
        }
    if (ioctl (slavefd, I_PUSH, "ldterm") < 0)  /* line discipline module */
        {
        printf("2nd ioctl failed: %d\n", errno);
        close(masterfd);
        close(slavefd);
        exit(-1);
        }
if (ioctl (slavefd, I_PUSH, "ttcompat") < 0)/* BSD/XENIX compat module */
        {
        printf("3rd ioctl failed: %d\n", errno);
        close(masterfd);
        close(slavefd);
        exit(-1);
        }
    printf("Success: pty acquired\n");
    close(masterfd);
    close(slavefd);
    exit(0);
}

 

home help back first fref pref prev next nref lref last post