• 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
Re: RunLoop in Helper Tool
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RunLoop in Helper Tool


  • Subject: Re: RunLoop in Helper Tool
  • From: Jean-Daniel Dupas <email@hidden>
  • Date: Sun, 15 Sep 2013 11:42:49 +0200

XPC is based on GCD. There is chance that your request handling occurs in a GCD thread and not on the main thread.

[NSRunLoop currentRunLoop] returns the current thread run loop. If you are not on the main thread, it will not work.

Try that instead: CFRunLoopStop(CFRunLoopGetMain());


Le 15 sept. 2013 à 10:32, Gerriet M. Denkmann <email@hidden> a écrit :

> I have a Helper Tool, running as root, started via SMJobBless and communicating vie Xpc.
>
> Works fine, but:
> 1. it cannot stop (CFRunLoopStop),
> 2. Timers never fire
> 3. NSRunLoop currentMode returns nil.
>
> Maybe all three things are related.
>
> To 1:
>
> if ( asked to quit )
> {
> 	NSRunLoop *currentRunLoop = [ NSRunLoop currentRunLoop ];
> 	CFRunLoopRef rl = [ currentRunLoop getCFRunLoop ];
> 	NSLog(@"%s will stop runloop %p",__FUNCTION__, rl);	//	rl ≠ NULL
> 	CFRunLoopStop ( rl );		//	runLoop will NOT stop
> }
>
> Helper Tool main:
>
> int main(int argc, const char * argv[])
> {
> 	@autoreleasepool
> 	{
> 		NSString * bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
> 		NSXPCListener *listener = [[NSXPCListener alloc] initWithMachServiceName: bundleIdentifier ];
> 		listener.delegate = ...;
> 		[listener resume];
> 		NSRunLoop *currentRunLoop = [NSRunLoop currentRunLoop];
> 		[ currentRunLoop run ];
> 	}
>
>    return EXIT_SUCCESS;
> }
>
>
> _______________________________________________
>
> Cocoa-dev mailing list (email@hidden)
>
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>
> Help/Unsubscribe/Update your Subscription:
>
> This email sent to email@hidden

-- Jean-Daniel





_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden


  • Follow-Ups:
    • Re: RunLoop in Helper Tool
      • From: "Gerriet M. Denkmann" <email@hidden>
References: 
 >RunLoop in Helper Tool (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Re: Helper tool
  • Next by Date: CGImageRef as a property of a cocoa object
  • Previous by thread: RunLoop in Helper Tool
  • Next by thread: Re: RunLoop in Helper Tool
  • Index(es):
    • Date
    • Thread