[launchd-dev] Programmatic interface to launchctl and some other questions, OS X 10.5

Rainer Brockerhoff rainer at brockerhoff.net
Tue Oct 26 10:50:22 PDT 2010


At 05:49 -0700 26/10/10, launchd-dev-request at lists.macosforge.org wrote:
>Date: Tue, 26 Oct 2010 10:13:09 +0100
>From: "Quinn \"The Eskimo!\"" <eskimo1 at apple.com>
>Message-ID: <AAB6BEB9-F4AF-4B93-A3D6-E49DB5C0ECC2 at apple.com>
>
>On 26 Oct 2010, at 03:55, Jerry Krinock wrote:
>
>> On 2010 Oct 25, at 18:01, eveningnick eveningnick wrote:
>>
>>> Also there's a /usr/include/launch.h file, which provides some kind of
>>> API, but i've no idea how to use it, and i am not sure if it gives any
>>> means to load/start/stop/unload agents. Maybe i could use it somehow?
>>
>> Anyone know what he's talking about?
>
>The routines in <launch.h> provide necessary services for launchd jobs (daemons and agents).  Specifically, a launchd job uses this API to check in with launchd.  See SampleD for an example of this.
>
><http://developer.apple.com/library/mac/#samplecode/SampleD/>
>
>If you need to manipulate the launchd state, you should use Service Management (if it's available and does what you want) or simply fork/exec launchctl.  And yes, it is both sad and a chore )-:

As a footnote to Quinn's reply, check out my post about using the launch.h API to check if your agent is running:
http://brockerhoff.net/blog/2009/02/02/cocoa-musings-pt-3/

This does work under 10.5.

HTH,
-- 
Rainer Brockerhoff  <rainer at brockerhoff.net>
Belo Horizonte, Brazil
"In the affairs of others even fools are wise
 In their own business even sages err."
Blog: http://brockerhoff.net/blog


More information about the launchd-dev mailing list