Xref: utzoo comp.lang.c:21360 comp.lang.c++:4520 Path: utzoo!attcan!utgpu!jarvis.csri.toronto.edu!dgp.toronto.edu!flaps From: flaps@dgp.toronto.edu (Alan J Rosenthal) Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: ttyname() - question Message-ID: <1989Aug31.165349.13125@jarvis.csri.toronto.edu> Date: 31 Aug 89 20:53:50 GMT References: <99@lkbpyr.UUCP> <1088@virtech.UUCP> <14481@haddock.ima.isc.com> <1093@virtech.UUCP> Lines: 49 cpcahil@virtech.UUCP (Conor P. Cahill) writes: >I beg to differ. If the open succeeded you will have gotten a file >descriptor for the "controlling terminal", not /dev/tty... >I can't imagine that there is a kernel out there that will return a >file descriptor associated with /dev/tty and then re-maps it to the >appropriate device for every read and write... FOR F***K'S SAKE DOES NO ONE CHECK THINGS OUT BEFORE POSTING? Script started on Thu Aug 31 16:40:46 1989 champlain.dgp% cat ttyname.c #include #include int main() { int fd; char *p; extern char *ttyname(); if ((fd = open("/dev/tty", O_RDWR)) < 0) perror("/dev/tty"); else if ((p = ttyname(fd)) == NULL) fprintf(stderr, "ttyname failed\n"); else printf("tty is %s\n", p); return(0); } champlain.dgp% cc ttyname.c champlain.dgp% a.out tty is /dev/tty champlain.dgp% ^D script done on Thu Aug 31 16:41:04 1989 That was on a sun running 3.5; I got the same output on an iris running sys V whose motd says "IRIX System V Release 4D1-3.1D". -- Posting etiquette: When I saw Karl's posting about /dev/tty, I was surprised and I thought it was wrong. But I didn't just bang on my followup key. I pressed ^Z and typed "ttyname