which is my login terminal

Mark Weiser mark at umcp-cs.UUCP
Tue Jul 1 13:13:24 AEST 1986


In article <34 at gec-rl-hrc.co.uk> nwh at gec-rl-hrc.co.uk (Nigel Holder Marconi) writes:
>
>   I have an application that needs to know whether I am logged
>on at the console to decide whether I can paint all over the
>sun bit-mapped screen.  I could be in suntools, a pty (either via
>suntools, remote login or any windowing system), the normal console,
>device, or an external port (eg. ttya).  What I really need to know
>is whether I actually logged in at the console for this session.
>As other people might want to run the application the solution must
>be general.  If I'm not on a pty then it is possible to use ttyname().

There is no sure fire method, but one I use is: check ttyname(0)
(i.e. of the file descripter underlying stdin).  If it is /dev/console,
assume you DO have screen access.  If that is not
/dev/console, then check for the existence of the WINDOW_GFX environment
variable.  If it is not set, assume you do not have screen access.
-- 
Spoken: Mark Weiser 	ARPA:	mark at maryland	Phone: +1-301-454-7817
CSNet:	mark at umcp-cs 	UUCP:	{seismo,allegra}!umcp-cs!mark
USPS: Computer Science Dept., University of Maryland, College Park, MD 20742



More information about the Comp.unix mailing list