OS X - Communication between launch daemon and launch agent

ⅰ亾dé卋堺 提交于 2019-12-06 05:13:36

问题


I am new to OS X and have to create an application having 2 parts - launch daemon and launch agent. The daemon is going to do stuff such as command execution, logging, etc and has to somehow communicate these results to launch agent (which would transfer them to a login item displaying a GUI, although that is a future step).

My question: How do I achieve this communication?. From what I have been able to gather so far after reading Apple docs is that my best bet is using CFSockets. Is there any alternate(simpler) way ? Does anybody have any sample tutorial/example/code that shows how to use CFSockets (I could not find any) ?.

PS: My question might be a duplicate of this one, but that question is not yet answered and so I thought of posting this.


回答1:


I was able to set up communication between my daemon and agent using CFSockets and it wasn't as bad as I had thought before. I followed the step-by-step instructions at : https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/UsingSocketsandSocketStreams.html (Writing a TCP-Based Server).

You could probably also try using plain BSD sockets. There is a simple example at : http://www.minek.com/files/unix_examples/poll.html (although I have not tried this out).

Good luck.



来源:https://stackoverflow.com/questions/11868069/os-x-communication-between-launch-daemon-and-launch-agent

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!