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

Damien Sorresso dsorresso at apple.com
Tue Oct 26 15:05:55 PDT 2010


On Oct 26, 2010, at 2:51 PM, Dave MacLachlan wrote:
> On Oct 26, 2010, at 5:49 AM, eveningnick eveningnick wrote:
>> 
>> I am wondering, if from the launchctl sources (i've heard they are
>> available) i could extract the code to load/start/unload/list the
>> agents, instead of calling the "launchctl" terminal application with
>> fork/exec and waiting in the pipe for their result (and parsing that
>> result). What i mean is - of course, launchctl and launchd can have
>> changed with time, and my application will become invalid, but so can
>> the launchctl's console output, that i'm parsing. And, for example,
>> when i expect the text "12345 1 com.mycompany.myagent" to be returned
>> with "launchctl list | grep", i may get something different and think
>> "Oh well, my agent is not running yet, let's start it again" (this is
>> just an example). Why is this solution considered to be better than
>> calling API's directly?
> 
> Perhaps these will be of use?
> 
> http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/GTMServiceManagement.c
> http://code.google.com/p/google-toolbox-for-mac/source/browse/trunk/Foundation/GTMServiceManagement.h

Be careful when using this. It will not work for submitting jobs which have Socket services.
-- 
Damien Sorresso
BSD Engineering
Apple Inc.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/launchd-dev/attachments/20101026/14b08d73/attachment.html>


More information about the launchd-dev mailing list