[comp.unix.programmer] How to determine tty device

dcon@cbnewsc.att.com (david.r.connet) (10/25/90)

Does anyone know how I can figure out the name of the tty device
I am on?  (Please don't say ttyname(3), I know that.)  The problem
is after opening communication directly to /dev/tty, I need to
figure out which device I'm actually on.  (In case it matters, I'm
on a SVR3.2.2 system.)  ttyname() just reports "/dev/tty".

Background: This is running under layers, and I need to identify
if this is the window that the system is going to use to write
messages to.  (I can't run in that window.)  I'm currently obtaining
the name of the device, stuffing it in a utmp structure and using
the getutline() call to see if there is a utmp entry.  I don't want
to assume that a user has not redirected stdin/stdout (strange things
happen when they do that, so I don't want to allow them that).

Please email me at "dcon@iwtng.att.com" as I don't regularly read
this group.

Thanks in advance.
Dave Connet