Is there any way to find real tty under shell layers?

Stephen J. Friedl friedl at vsi.UUCP
Sun Mar 20 08:21:36 AEST 1988


In article <1098 at its63b.ed.ac.uk>, simon at its63b.ed.ac.uk (ECSC68 S Brown CS) writes:
> In article <3932 at whuts.UUCP> paul at whuts.UUCP (KOLB) writes:
> >>In article <352 at vsi.UUCP>, friedl at 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 at vsi.com
{uunet, attmail, ihnp4!amdcad!uport}!vsi!friedl



More information about the Comp.unix.questions mailing list