Emulating Leopard launchd.plist behavior under Tiger
Emulating Leopard launchd.plist behavior under Tiger
- Subject: Emulating Leopard launchd.plist behavior under Tiger
- From: Maxim Zhuravlev <email@hidden>
- Date: Tue, 7 Jul 2009 16:57:02 +0400
Hi, all.
I need the following launch daemon behavior both on Tiger and Leopard:
1) The daemon should support RunAtLoad set to true or false, both.
2) It should be kept alive unless exited successfully.
3) It should support launching on-demand.
As for Leopard, the following plist should do the job:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>LD_LIBRARY_PATH</key>
<string>/path/to/daemon/specific/libraries</string>
</dict>
<key>Label</key>
<string>com.yourcompany.yourdaemon/string>
<key>ProgramArguments</key>
<array>
<string>/path/to/daemon</string>
<string>-arg1</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>WorkingDirectory</key>
<string>/path/to/working/directory</string>
<key>MachServices</key>
<dict>
<key>com.yourcompany.yourdaemon.service</key>
<true/>
</dict>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
</dict>
</plist>
As for Tiger, assume the following plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
"http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>EnvironmentVariables</key>
<dict>
<key>LD_LIBRARY_PATH</key>
<string>/path/to/daemon/specific/libraries</string>
</dict>
<key>Label</key>
<string>com.yourcompany.yourdaemon</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/daemon</string>
<string>-arg1</string>
</array>
<key>RunAtLoad</key>
<false/>
<key>WatchPaths</key>
<array>
<string>/path/to/watch</string>
</array>
<key>WorkingDirectory</key>
<string>/path/to/working/directory</string>
</dict>
</plist>
This plist doesn't implement keeping alive. I could implement it the
way most Tiger system daemons do - through bootstrap:
bootstrap_create_server() with on-demand set to false, then
bootstrap_create_service(), bootstrap_check_in(). On successful exit
bootstrap_register() service with MACH_PORT_NULL.
The problem is: I can't pass environment variables this way
(LD_LIBRARY_PATH specifically). Any solution?
Thanks in advance,
- Maxim.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden