3 ms·
> It's also mentioned in Mac OS X Internals: A Systems Approach, FWIW. It's funny you should mention this. After someone sent me an amazing pull request using
by gnachman 7y ago
> It's also mentioned in Mac OS X Internals: A Systems Approach, FWIW.
It's funny you should mention this. After someone sent me an amazing pull request using this call, I thought "hm, this should be in Mac OS X Internals: A Systems Approach. Why didn't I see it?" So I looked it up, and yes, it's there, but there's nowhere near enough context or description for it to be of use to anyone but (at most) the author. Here's what it says:
The /usr/libexec/StartupItemContext program can be used to run an executable in the startup context—that is, the context in which the Mac OS X startup items run. It works by calling bootstrap_parent() repeatedly until it has reached the startup (root) context. It then sets the port as its own bootstrap port, after which it can execute the requested program.
The automatic relaunching of servers by the Bootstrap Server is useful for creating crash-resistant servers. However, it is neither necessary not advisable to create production servers by directly using the Bootstrap Server interface. Beginning with MacOS X 10.4, the launch API, as exported through <launch.h>, should be used. With this caveat, let us look at two examples of using the Bootstrap Server interface.
[an example that shows how to list all known services]
[a rather complex example that creates a bootstrap service and maybe uses bootstrap_parent somewhere]
There are bits of wisdom in this wonderfully written (and of course now obsolete) tech note:
https://developer.apple.com/library/archive/technotes/tn2083/_index.html https://developer.apple.com/library/archive/technotes/tn2083...
But of course, most people just copy-paste from the code Apple has (I would guess grudgingly) made open-source and we hope for the best.