michael@maui.cs.ucla.edu (12/27/88)
I am having trouble opening a terminal (machine: 3b1, os: S5 R2,
version 3.51a). I cannot get this to work
extern int errno;
main()
{
int fd;
fd = open ("/dev/tty000", 2);
perror();
printf ("%d %d\n", fd, errno);
}
The result of this is error 19, no such device. My system has /dev/tty000
as major #0, minor #0.
Michael
roe@unibase.UUCP (Roe Peterson) (01/05/89)
From article <19192@shemp.CS.UCLA.EDU>, by michael@maui.cs.ucla.edu: > I cannot get this to work: > > extern int errno; > main() > { > int fd; > fd = open ("/dev/tty000", 2); > perror(); ** problem here - should be perror(""); > printf ("%d %d\n", fd, errno); > } > > The result of this is error 19, no such device. I assume you have read/write permission. I'm not sure why you are getting "no such device" errors on the tty line, but I know this for sure: if you are opening a tty line, it ALWAYS pays off to open the thing with O_NDELAY set, to avoid problems with carrier detect not being there. Then, make sure the line is on in CLOCAL mode. Fragment follows (for system V): #include <sys/termio.h> #include <sys/fcntl.h> struct termio ttymode; int fd; fd = open ("/dev/tty000", O_RDWR|O_NDELAY); ioctl(fd,TCGETA,&ttymode); ttymode.c_cflag |= CLOCAL; ioctl(fd,TCSETA,&ttymode); close(open("/dev/tty000",O_RDWR)); The close(open()) is required to shut off the O_NDELAY setting. I know that the fcntl manual says you can do it with an fcntl call, but the device driver is not reset by this - use the close(open()). -- Roe Peterson uunet!attcan!utgpu!tmsoft!mcl!unibase!roe