getting users' tty # into a C program
Karl Heuer
karl at haddock.ima.isc.com
Tue Mar 7 05:48:37 AEST 1989
>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 at haddock.isc.com), The Walking Lint
More information about the Comp.lang.c
mailing list