atty on Sun 3

Michael Glad glad at daimi.dk
Sat Jun 3 22:34:49 AEST 1989


I see no need to discuss the compiler flags used in compiling atty 
on Suns.

A few days ago, I compiled atty and tried to run it with the same
disappointing result as reported in this news group. 

I recompiled it using -g and used gdb (the nice GNU debugger) to
locate the crash.

Atty core dumps because it calls abort. It calls abort because an pty
ioctl fails. The ioctl fails because it tries to set terminal modes
on the master side of the pty instead of on the slave side.

I don't know if that's possible on other systems but it won't work on
SunOS 4.0 suns, see the enclosed program:

#include <sys/file.h>
#include <sys/types.h>
#include <sys/termio.h>
#include <sys/termios.h>

/* Michael Glad, glad at daimi.dk, 1989-06-03 */

main(argc,argv)
  int argc;
  char **argv;
  { int s;
    struct termios t;
  
    /* Too lazy to search for a pty, let's hope this one is free */
    /* Change it if not configured in your kernel                */

    if((s=open("/dev/ptyr0",O_RDONLY))<0)
      { perror("couldn't open pty");
        exit(1);
      }

    if(ioctl(s,TCGETS,(char*)&t)<0)
      { perror("ioctl failed");
        exit(1);
      }

    close(s);

    exit(0);

  }

When compiled using gcc or cc it produces the reported error message:

"Inappropriate ioctl for device".

I think atty needs patches for Sun's. I'm not going to do anything
about it as I'm very satisfied with the command editing facilities
in tcsh (a patched csh).

/Michael Glad

glad at daimi.dk



More information about the Comp.sources.bugs mailing list