How to determine tty device

david.r.connet dcon at cbnewsc.att.com
Thu Oct 25 23:57:40 AEST 1990


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 at iwtng.att.com" as I don't regularly read
this group.

Thanks in advance.
Dave Connet



More information about the Comp.unix.programmer mailing list