Re: Current active login session
Re: Current active login session
- Subject: Re: Current active login session
- From: Dreamcat4 <email@hidden>
- Date: Sat, 21 Aug 2010 12:32:46 +0100
On Sat, Aug 21, 2010 at 3:09 AM, Dave Keck <email@hidden> wrote:
> I use the utmpx APIs to determine the existing console users from a
> daemon process; see the UTXplorer example (which I believe Quinn
> wrote?).
>
> ==========
>
> #import <utmpx.h>
>
> - (NSSet *)userNamesForExistingUserSessions
> {
>
> struct utmpx *currentEntry = nil;
> NSMutableSet *result = nil;
>
> result = [NSMutableSet set];
>
> setutxent();
>
> while (currentEntry = getutxent())
> {
>
> /* Verify that we have a user and that currentEntry's session is a
> GUI ('console') session */
Sorry, does this return only the user active in the foreground
(visible window)? Or the list of all users (currently active or not)
in fast user switching?
>
> if (currentEntry->ut_type == USER_PROCESS &&
> !strcmp(currentEntry->ut_line, "console"))
> [result addObject: [NSString stringWithUTF8String:
> currentEntry->ut_user]];
>
> }
>
> endutxent();
>
> return result;
>
> }
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Darwin-kernel mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden