Xref: utzoo comp.sys.att:5099 comp.unix.questions:10942 Path: utzoo!attcan!utgpu!tmsoft!mcl!unibase!roe From: roe@unibase.UUCP (Roe Peterson) Newsgroups: comp.sys.att,comp.unix.questions Subject: Re: Help opening a terminal Message-ID: <110@unibase.UUCP> Date: 4 Jan 89 22:56:01 GMT References: <19192@shemp.CS.UCLA.EDU> Organization: EMIS Consulting, Regina, Saskatchewan, Canada Lines: 42 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 #include 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