getting users' tty # into a C program
Marco Zagha
marcoz at MARCOZ.BOLTZ.CS.CMU.EDU
Mon Mar 6 23:50:01 AEST 1989
In article 52746 at yale-celray.yale.UUCP> spolsky-joel at CS.YALE.EDU (Joel Spolsky) writes:
> failing that try fd=popen("tty"); fscanf(fd,"%s",ttyname); close(fd)
popen returns a FILE pointer. To close this file pointer use pclose(),
not close(). I think this is what should be done (as you said,
failing ttyname()):
FILE *f;
f=popen("/usr/bin/tty","r"); fscanf(f,"%s",ttyname); pclose(f)
== Marco (marcoz at cs.cmu.edu)
--
More information about the Comp.lang.c
mailing list