Mailing Lists: Apple Mailing Lists
Image of Mac OS face in stamp
Re: Alternative to bootstrap_register?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Alternative to bootstrap_register?

Le 18 nov. 2009 à 16:07, Uli Kusterer a écrit :

On 17.11.2009, at 19:16, Jean-Daniel Dupas wrote:
Does anyone know what paragraph 3) means to achieve and how, possibly with a short example?

To be noted, the open source CFMessagePortCreateLocal() still uses bootstrap_register years later after the API has been marked as deprecated.

Note really. It uses bootstrap_register2 which is a SPI and not deprecated.

 Doesn't help us, we can't use an SPI either :-/

Now it depends what you want to do.
If you plan to register and checkin the service in the same process, it can be done using the NSMachBootstrapServer API.

 They're separate processes, sadly.

I'm not sure my mail was clear.

First case:
Parent process create a receive right using [NSMachPort port].
It register it using an UUID string as the name for example using -[NSMachBootstrapServer registerPort:name:].
It starts a child process passing it the service name as argument (or using env variable).
The child process get a send right using the -[NSMachBootstrapServer portForName:] method

Your Mach channel is up.

Now if you want to register the service, lookup, and wait that an other process checked-in, it's a little more complex.

An approach may be to use a temporary launchd service. The new ServiceManagement Framework provide a way to dynamically register a launchd service (SMJobSubmit). You can register your service with "LaunchOnlyOnce" flag set so it will be automatically unregistred just after launch.

Second case. You want to have a send right on a child process.

Parent process register a service using launchd API (and pass an UUID string as service name).
Parent query a send right using bootstrap_lookup. -> launchd start the child process.
Child process retrieves the receive right using the launchd API.

 Your Mach channel is up.

If you need this configuration (child has receive right, parent has send right), an other way is to use method 1 and then the child process can create a port and send a send right to the parent using the first mach channel.

 But then we wouldn't be able to locate the service if it is already running. :-(

-- Uli Kusterer
"The witnesses of TeachText are everywhere..."

-- Jean-Daniel

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

 >Alternative to bootstrap_register? (From: Uli Kusterer <email@hidden>)
 >Re: Alternative to bootstrap_register? (From: Jean-Daniel Dupas <email@hidden>)
 >Re: Alternative to bootstrap_register? (From: Uli Kusterer <email@hidden>)

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.