I am trying to get a list of current logged in users using the getutxent()
function defined in apple's <utmpx.h>
. The test code I am using is this:
#include <stdio.h>
#include <utmpx.h>
int main(void) {
setutxent();
while (1) {
struct utmpx *user_info = getutxent();
if (user_info == NULL) break;
printf("%s\n", user_info->ut_user);
}
return 0;
}
I am testing it with only one logged in user. The output I get is this:
myusername
myusername
Why does my username appear twice? Would that happen if there were multiple users?
Details about my mac: