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 17 nov. 2009 à 18:27, Uli Kusterer a écrit :

> In <servers/bootstrap.h> there is the following note about the bootstrap_register() call:
> * This API is deprecated. Old scenarios and recommendations:
> *
> * 1) Code that used to call bootstrap_check_in() and then bootstrap_register()
> *    can now always call bootstrap_check_in().
> *
> * 2) If the code was registering a well known name, please switch to launchd.
> *
> * 3) If the code was registering a dynamically generated string and passing
> *    the string to other applications, please rewrite the code to send a Mach
> *    send-right directly.
> In case of suggestion #3, the application that used to call bootstrap_register only has the pid of the target application to which to "send a Mach send-right directly".
> In order to send a Mach send right however one needs a send right itself to a port to which the target application has receive rights. In order to get that send right, the target application itself also needs to send this application a Mach send right, however in order send that send right it also needs a send right to send it and the loop never ends.

That's why the bootstrap server was invented ;-)

> 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.

That said, this question reminds me a question I posted here 10 month ago :-)

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.

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.
If you need 10.5 compatibility, you can also use the plain launchd API. A little less friendly, but it works too.

-- 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>)

Visit the Apple Store online or at retail locations.

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2011 Apple Inc. All rights reserved.