Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!tut.cis.ohio-state.edu!cs.utexas.edu!sm.unisys.com!ism780c!haddock!karl From: karl@haddock.ima.isc.com (Karl Heuer) Newsgroups: comp.lang.c Subject: Re: getting users' tty # into a C program Summary: don't bother with popen() Message-ID: <11958@haddock.ima.isc.com> Date: 6 Mar 89 19:48:37 GMT References: <441@lakesys.UUCP> <9794@smoke.BRL.MIL> <52746@yale-celray.yale.UUCP> <4418@pt.cs.cmu.edu> Reply-To: karl@haddock.ima.isc.com (Karl Heuer) Organization: Interactive Systems, Boston Lines: 11 >FILE *f; >f=popen("/usr/bin/tty","r"); fscanf(f,"%s",ttyname); pclose(f) Better, but it should probably be noted that this is LESS likely to work than the ttyname() function it's covering for. (I'd be extremely surprised to hear of a system where this works, but ttyname() doesn't.) Use ttyname(). It isn't in the pANS, of course, but it's still more portable than any form of the popen() hack. Karl W. Z. Heuer (ima!haddock!karl or karl@haddock.isc.com), The Walking Lint