[launchd-dev] Launchd "System" session type

Quinn "The Eskimo!" eskimo1 at apple.com
Tue Jul 23 01:56:46 PDT 2013


On 21 Jul 2013, at 02:37, Michael <keybounce at gmail.com> wrote:

> Perhaps a better question: Where are these documented, 

Some of this stuff is documented in the "Daemons and Services Programming Guide".

<https://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPSystemStartup/Chapters/Introduction.html%23//apple_ref/doc/uid/10000172i>

But probably the best reference is Technote 2083 "Daemons and Agents".

<https://developer.apple.com/library/mac/#technotes/tn2083/_index.html>

> why does the man page for "launchctl" list them but not define them, nor reference the file/tech document where they are defined?

You should feel free to file a bug against the man page requesting that.

<http://developer.apple.com/bugreporter/>

> But actually understanding -- and being able to predict -- what is actually happening/what will happen (including why I see launchd running jobs for people not logged on, usually mdworker), that's still beyond me.

In the general case, launchd is a highly dynamic system, which makes predicting its behaviour somewhat tricky. For example, consider gssd.  It's on-demand trigger is:

<dict>
  <key>com.apple.gssd</key>
  <dict>
    <key>HostSpecialPort</key>
    <integer>19</integer>
  </dict>
</dict>

which means it launches when other code either a) messages a Mach port registered as "com.apple.gssd" in the Mach bootstrap namespace, or b) messages the HOST_GSSD_PORT Mach special port.  Both of these can be done by any process on the system, and the latter can be done by kernel code as well (such as the SMB VFS plug-in).  From a launchd perspective it's hard to predict--and, in the bigger picture, it just doesn't matter--when other components of the system will do this.

In the specific case of mdworker, all the mdworker jobs are carefully managed by the Spotlight infrastructure, and the details of that management are not clearly visible to you (note that all the mdworker jobs have a single "MachService" on-demand trigger, which isn't very enlightening).  Spotlight starts an particular flavour of mdworker when it has work for that flavour to do; launchd is involved in the mechanics of starting and tracking the job, but not the decision about which job to start when.

> (and, I just realized, this list is launchd-dev; is there a launchd-users list?)

No, but this is a perfectly reasonable place to just such things IMO.

Share and Enjoy
--
Quinn "The Eskimo!"                    <http://www.apple.com/developer/>
Apple Developer Relations, Developer Technical Support, Core OS/Hardware




More information about the launchd-dev mailing list