Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!caip!ut-sally!seismo!umcp-cs!mark From: mark@umcp-cs.UUCP (Mark Weiser) Newsgroups: net.unix-wizards,net.unix Subject: Re: which is my login terminal Message-ID: <2222@umcp-cs.UUCP> Date: Mon, 30-Jun-86 23:13:24 EDT Article-I.D.: umcp-cs.2222 Posted: Mon Jun 30 23:13:24 1986 Date-Received: Wed, 2-Jul-86 03:22:49 EDT References: <34@gec-rl-hrc.co.uk> Reply-To: mark@maryland.UUCP (Mark Weiser) Organization: University of Maryland, Dept. of Computer Sci. Lines: 20 Xref: watmath net.unix-wizards:18683 net.unix:8469 In article <34@gec-rl-hrc.co.uk> nwh@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@maryland Phone: +1-301-454-7817 CSNet: mark@umcp-cs UUCP: {seismo,allegra}!umcp-cs!mark USPS: Computer Science Dept., University of Maryland, College Park, MD 20742