[launchd-dev] Launchd API

Rainer Brockerhoff rainer at brockerhoff.net
Mon Feb 2 11:01:42 PST 2009


At 07:00 -0800 02/02/09, launchd-dev-request at lists.macosforge.org wrote:
>Date: Mon, 2 Feb 2009 09:32:29 +0000
>From: Quinn <eskimo1 at apple.com>
>Message-ID: <p06240803c5ac6d770052@[10.0.40.15]>
>
>At 22:03 +0100 28/1/09, Xavier Gu?rin wrote:
>>Reading launchctl.c I've already been able to do
>>some of the polling code of the agent (even
>>though some data structure are still a complete
>>mystery as I speak), but the load/unload part
>>seems really intricate, and I'm afraid to be
>>obliged to use execve + launchctl to make it
>>work.
>
>Right now the <launch.h> API is only rated for
>daemons checking in with launchd (ala SampleD).
>It is not really designed for job management.
>Rather, we recommend that folks do their job
>management by fork/exec of launchctl.

Despite your recommendation :-) I wrote, or rather, repurposed some code from the launchd project to get job status info using <launch.h>:
http://www.brockerhoff.net/bb/viewtopic.php?p=2647#2647

Seems to work well, and if the details change out from under it, it will stop working gracefully.

I wouldn't do that for starting/stopping jobs though; too complex. I suppose I should file a bug to request to get some of the launchctl functionality in CoreFoundation... CFLaunchGetJobInfo, CFLaunchLoadJob, etc.

-- 
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."
Weblog: http://www.brockerhoff.net/bb/viewtopic.php


More information about the launchd-dev mailing list