[launchd-dev] launchctl unload not working

Kevin Van Vechten kvv at apple.com
Thu Nov 29 16:32:05 PST 2007



On Nov 29, 2007, at 11:36 AM, James Bucanek wrote:

> The helper process appears in both contexts, but its communications  
> port doesn't appear in the bootstrap namespace. The helper  
> successfully registers its distribute objects connection port, but  
> when the scheduler process attempt to connect with that port it fails.

> It appears that the problem is this: The scheduler is started by the  
> bootstrap launchd. It creates and registers a Mach port for  
> communications. That works. The scheduler then launches a child  
> process (the helper, using NSTask), but when it tries to connect  
> with the Mach port created by the helper that doesn't work. No  
> process can see the port and it doesn't appear in the boostrap  
> namespace according to launchctl, even though the helper is told  
> that the port was successfully created and registered.


Just to clear up some terminology...

A bootstrap is a namespace for looking up mach services by name.  I  
would describe the above as "the helper's port does not appear in the  
root bootstrap."  And "the scheduler is started by the root launchd."

> crocodile:~ james$ ~/Desktop/seedaemons.sh

> per-user
> 789 -   [0x0-0x4d04d].com.qrecall.client
> 115 -   [0x0-0x16016].com.qrecall.monitor
> 1182    -   0x10df80.QRecallHelper
> 1170    -   0x10dcc0.QRecallScheduler
> 1167    -   0x1109d0.QRecallScheduler
> per-user namespace
> A  QRecallMonitor
> root
> 1182    -   0x10b0b0.QRecallHelper
> 1170    -   0x10be90.QRecallScheduler
> 1167    -   com.qrecall.scheduler.501
> root namespace
> A  QRecallScheduler.501


This output doesn't actually tell us which bootstrap the QRecallHelper  
or QRecallScheduler are running in.  All it tells us is that both of  
these processes have made themselves known to each of these launchd  
processes (which could have happened a number of ways).

The fact that the lookup fails in the root bootstrap strongly implies  
the helper is registered in the per-user bootstrap (if it's registered  
at all).  What is the name of the helper's registration?  (I'm  
assuming it's neither "QRecallScheduler.501" nor "QRecallMonitor"  
which are the only two names you've listed.)

As an aside, which API are you using to register the mach port?  
bootstrap_register? CFMessagePort?

- Kevin


More information about the launchd-dev mailing list