Re: RunLoop in Helper Tool

2013-09-16 Thread Uli Kusterer
On 16 Sep 2013, at 01:10, Greg Parker gpar...@apple.com wrote: And of course every Cocoa app halts by calling exit(). NSApplicationMain() never returns. (I'm pretty sure it doesn't attempt to stop the main run loop, either.) It does go and close all documents and send

Re: RunLoop in Helper Tool

2013-09-16 Thread Marcel Weiher
On Sep 16, 2013, at 9:12 , Uli Kusterer witness.of.teacht...@gmx.net wrote: On 16 Sep 2013, at 01:10, Greg Parker gpar...@apple.com wrote: And of course every Cocoa app halts by calling exit(). NSApplicationMain() never returns. (I'm pretty sure it doesn't attempt to stop the main run

RunLoop in Helper Tool

2013-09-15 Thread Gerriet M. Denkmann
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

Re: RunLoop in Helper Tool

2013-09-15 Thread Jean-Daniel Dupas
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

Re: RunLoop in Helper Tool

2013-09-15 Thread Gerriet M. Denkmann
On 15 Sep 2013, at 16:42, Jean-Daniel Dupas devli...@shadowlab.org wrote: XPC is based on GCD. There is chance that your request handling occurs in a GCD thread and not on the main thread. Correct. NSThread tells me: mainThread NSThread: 0x7f92b14096a0{name = (null), num = 1}

Re: RunLoop in Helper Tool

2013-09-15 Thread Marcel Weiher
On Sep 15, 2013, at 10:32 , Gerriet M. Denkmann gerr...@mdenkmann.de wrote: I have a Helper Tool, running as root, started via SMJobBless and communicating vie Xpc. Works fine, but: 1. it cannot stop (CFRunLoopStop), Do all the cleanup you want to do and then exit(0) ? Marcel

Re: RunLoop in Helper Tool

2013-09-15 Thread Kevin Meaney
Interesting that you should say that. I was doing exit(0) but after reading this discussion I thought it would be cleaner to do the CFRunLoopStop on the main thread. Unfortunately I'd broken my LaunchAgent doing some other stuff at the time and just now I've got stuff working and then I've

Re: RunLoop in Helper Tool

2013-09-15 Thread Jean-Daniel Dupas
Le 15 sept. 2013 à 16:23, Gerriet M. Denkmann gerr...@mdenkmann.de a écrit : On 15 Sep 2013, at 16:42, Jean-Daniel Dupas devli...@shadowlab.org wrote: XPC is based on GCD. There is chance that your request handling occurs in a GCD thread and not on the main thread. Correct. NSThread

Re: RunLoop in Helper Tool

2013-09-15 Thread Marcel Weiher
On Sep 15, 2013, at 17:04 , Kevin Meaney k...@yvs.eu.com wrote: On 15 Sep 2013, at 15:30, Marcel Weiher marcel.wei...@gmail.com wrote: Do all the cleanup you want to do and then exit(0) ? I was doing exit(0) but after reading this discussion I thought it would be cleaner to do the

Re: RunLoop in Helper Tool

2013-09-15 Thread Greg Parker
On Sep 15, 2013, at 10:50 AM, Marcel Weiher marcel.wei...@gmail.com wrote: On Sep 15, 2013, at 17:04 , Kevin Meaney k...@yvs.eu.com wrote: On 15 Sep 2013, at 15:30, Marcel Weiher marcel.wei...@gmail.com wrote: Do all the cleanup you want to do and then exit(0) ? I was doing exit(0) but