Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ncar!husc6!yale!spolsky-joel From: spolsky-joel@CS.YALE.EDU (Joel Spolsky) Newsgroups: comp.lang.c Subject: Re: getting users' tty # into a C program Message-ID: <52746@yale-celray.yale.UUCP> Date: 5 Mar 89 22:42:15 GMT References: <441@lakesys.UUCP> <9794@smoke.BRL.MIL> Sender: root@yale.UUCP Reply-To: spolsky-joel@CS.YALE.EDU (Joel Spolsky) Organization: Yale University Computer Science Dept, New Haven CT 06520-2158 Lines: 16 In article <9794@smoke.BRL.MIL> gwyn@brl.arpa (Doug Gwyn (VLD/VMB) ) writes: >In article <441@lakesys.UUCP> davek@lakesys.UUCP (Dave Kraft) writes: >>I am writing a C program that need a user's tty number (i.e. tty3A). Is there >>any internal/external function that can accomplish this? > >Most UNIX systems have a ttyname() library function for doing this. failing that try fd=popen("tty"); fscanf(fd,"%s",ttyname); close(fd) +----------------+----------------------------------------------------------+ | Joel Spolsky | bitnet: spolsky@yalecs.bitnet uucp: ...!yale!spolsky | | | internet: spolsky@cs.yale.edu voicenet: 203-436-1483 | +----------------+----------------------------------------------------------+ #include