• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
SCDynamicStore ConsoleUser change callback not working on Tiger?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SCDynamicStore ConsoleUser change callback not working on Tiger?


  • Subject: SCDynamicStore ConsoleUser change callback not working on Tiger?
  • From: Daniel Becker <email@hidden>
  • Date: Fri, 6 May 2005 10:05:23 +0200

Hi all,

I have a daemon which registers a callback with SCDynamicStore to get notified of console user changes. This seems to work just fine on Panther, but it appears the callback never gets triggered on Tiger. Were there any relevant changes in Tiger's SCDynamicStore that I should be aware of? Any other suggestions? (The relevant code is given below.)

Daniel


void ConsoleUserChangedCallBackFunction(SCDynamicStoreRef store, CFArrayRef changedKeys, void * context) { [...] }

int main (int argc, const char * argv[])
{
SCDynamicStoreContext context = {0, NULL, NULL, NULL, NULL};
SCDynamicStoreRef session = NULL;
CFStringRef consoleUserNameChangeKey = NULL;
CFArrayRef notificationKeys;
CFRunLoopSourceRef rls = NULL;
FILE * pid_file;
daemon(0,0);
syslog(1, "Daemon starting up with PID %d.\n", getpid());
session = SCDynamicStoreCreate(NULL, CFSTR(kProgramName),
ConsoleUserChangedCallBackFunction, &context);
if (session == NULL)
{
syslog(1, "Couldn't create DynamicStore session!\n");
return 1;
}
consoleUserNameChangeKey = SCDynamicStoreKeyCreateConsoleUser(NULL);
if (consoleUserNameChangeKey == NULL)
{
CFRelease(session);
syslog(1, "Couldn't create ConsoleUser key!\n");
return 1;
}
notificationKeys = CFArrayCreate(NULL, (void*)&consoleUserNameChangeKey,
(CFIndex)1, &kCFTypeArrayCallBacks);
CFRelease(consoleUserNameChangeKey);
if (notificationKeys == NULL)
{
CFRelease(session);
syslog(1, "Couldn't create notification key array!\n");
return 1;
}
if (SCDynamicStoreSetNotificationKeys(session, notificationKeys, NULL) == FALSE)
{
CFRelease(notificationKeys);
CFRelease(session);
syslog(1, "Couldn't set up dynamic store notification!\n");
return 1;
}
CFRelease(notificationKeys);
rls = SCDynamicStoreCreateRunLoopSource(NULL, session, (CFIndex)0);
pid_file = fopen(kPIDFile, "w");
fprintf(pid_file, "%d\n", getpid());
fclose(pid_file);
CFRunLoopAddSource(CFRunLoopGetCurrent(), rls, kCFRunLoopDefaultMode);
CFRelease(rls);
CFRunLoopRun();
unlink(kPIDFile);
return 0;
}


_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: SCDynamicStore ConsoleUser change callback not working on Tiger?
      • From: Stéphane Sudre <email@hidden>
  • Prev by Date: Re: Tiger and libreadline
  • Next by Date: Re: Darwin 8.0 Source Code Available
  • Previous by thread: Re: writing a new GUI environment
  • Next by thread: Re: SCDynamicStore ConsoleUser change callback not working on Tiger?
  • Index(es):
    • Date
    • Thread