Is there any way to find real tty under shell layers?
KOLB
paul at whuts.UUCP
Sun Mar 20 09:58:23 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.
Have you tried to run the program? Here it is again:
#include <sys/types.h>
#include <utmp.h>
#include <stdio.h>
main()
{
struct utmp *utmp, *getutent();
char *q;
q = ttyname(0)+5;
while ((utmp = getutent()) != NULL) {
if ( (utmp->ut_type == USER_PROCESS) &&
(strncmp(utmp->ut_line, q, strlen(q)) == 0) )
printf("tty%d\n", atoi(utmp->ut_id));
}
}
As I said in my earlier reply to Steve Friedl, inittab's ID field
(this ID field becomes utmp->ut_id) has to be corresponded to the
tty number. Ie:
123:2:respawn:/etc/getty -t 60 tty123
^^^ correspond to ^^^
> The only way I can think of is to look in /dev/kmem ....
Another setgid to sys program!
> Of course, the real problem is that utmp is simply not good enough any more-
> it was fine back in the Good Old Days, but when you have windows and ptys and
> multiplexing and other good stuff like this, it loses badly.
I tried the program with shl and layers, and it works. The
Good Old Days are still here :)
Paul Ho
More information about the Comp.unix.questions
mailing list