次のような plist を作成します。
<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd\">
<!-- My version "1.2.3" -->
<plist version=\"1.0\">
<dict>
<key>Disabled</key>
<false/>
<key>Label</key>
<string>MyPlistName</string>
<key>ProgramArguments</key>
<array>
<string>MyDaemonBinPath</string>
<string>-log</string>
<string>MyLogLevel</string>
<string>-launchd</string>
</array>
<key>Sockets</key>
<dict>
<key>Listeners</key>
<dict>
<key>SockFamily</key>
<string>Unix</string>
<key>SockPathMode</key>
<integer>438</integer>
<key>SockPathName</key>
<string>MySocketName</string>
</dict>
</dict>
<key>StandardErrorPath</key>
<string>MySTDERRLogPath</string>
<key>WaitForDebugger</key>
<false/>
<key>inetdCompatibility</key>
<dict>
<key>Wait</key>
<false/>
</dict>
</dict>
</plist>
/Library/LaunchDaemons に配置します
次に、次のコマンドを実行します。
/bin/launchctl unload /Library/LaunchDaemons/MyPlistName.plist
/bin/launchctl load /Library/LaunchDaemons/MyPlistName.plist
plist で指定されたソケットに接続し、次のように入力すると、デーモンが起動します。
launchctl list
デーモンは登録されていますが、ログアウトして再度ログインし、再度リストを要求すると、登録されなくなり、ソケットに接続してデーモンを起動できません。
これをセッション間で永続化するために、plistまたはデーモンに設定する必要がある特別な権限はありますか?