Path: utzoo!mnetor!uunet!vsi!friedl From: friedl@vsi.UUCP (Stephen J. Friedl) Newsgroups: comp.unix.questions Subject: Re: Is there any way to find real tty under shell layers? Message-ID: <415@vsi.UUCP> Date: 19 Mar 88 22:21:36 GMT References: <3932@whuts.UUCP> <1098@its63b.ed.ac.uk> Organization: V-Systems, Inc. -- Santa Ana, CA Lines: 24 In article <1098@its63b.ed.ac.uk>, simon@its63b.ed.ac.uk (ECSC68 S Brown CS) writes: > In article <3932@whuts.UUCP> paul@whuts.UUCP (KOLB) writes: > >>In article <352@vsi.UUCP>, friedl@vsi.UUCP (Stephen J. Friedl) writes: > >> Does anybody know any way to find out the "real" terminal > >> name when running under shell layers in Sys V? > > > > [description of doing this using getutent() to search for a ut_line > > that looks like ttyname(0)] > > But shl stamps an entry for the current layer "/dev/sxtNNN" in /etc/utmp, > so this won't work. [...] Paul's method works quite well but not in the rigorous manner you probably assume. Yes, you get the "/dev/sxtNNN" back from utmp that matches the return from ttyname(), but then you look at utmp->ut_id. This field, which is defined in /etc/inittab, bears a coincidental relationship to the real tty name: if the id is "12" then we are on "tty12". Yes, this relationship must be maintained in /etc/inittab, and there are special cases ("co" is console, "ct" is contty) but for practical use it works very nicely (thanks again Paul!). -- Steve Friedl friedl@vsi.com {uunet, attmail, ihnp4!amdcad!uport}!vsi!friedl