> I'm really stuck on a UNIX/C assignemnt, that emulates the WHO command by
> using the wtmp file. I know the structure defined in <utmp.h>, however, I
> find that there are far more logins than logouts (indicated by a blank
> What I'm doing is creating a doubly linked list, and inserting each
> username into it. Later, when I encounter logouts, I disconnect and free
> the entry which has been logged out. But there are so many more logins
> than logouts, that people who aren't on the system (by the who command)
> still show up in my program.
> Is there something that I'm missing here? If anyone has suggestions, I'd
> really appreciate your help.
Are you allowed to use the utmp or utmpx(Sun) files instead of wtmp? the utmp
file is the closest thing to a list of current users that you can get. In
fact, who and a number of other commands use it for their information. It can
get a little confused sometimes if someone does an unclean logout, but even
the writers of "who" couldn't circumvent that problem.
Using getutent() and ttyslot() you could even code "whoami". I hope some of
this was at least partially useful. Good luck.
JCPenney Company AIT/TS