OS X - 启动守护程序和启动代理之间的通信 [英] OS X - Communication between launch daemon and launch agent

查看:267
本文介绍了OS X - 启动守护程序和启动代理之间的通信的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是OS X的新手,必须创建一个有2个部分的应用程序 - 启动守护进程和启动代理。守护进程将要做诸如命令执行,日志记录等的东西,并且必须以某种方式将这些结果传递给启动代理(这将把它们转移到显示GUI的登录项,尽管这是未来的步骤)。

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).

我的问题:
如何实现此通信?从我在阅读Apple文档之后到目前为止可以收集的是,我最好的选择是使用CFSockets。是否有任何替代(更简单)的方式?任何人都有任何示例教程/示例/代码,显示如何使用CFSockets(我找不到任何)。

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:我的问题可能与

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

推荐答案

这个问题还没有回答,所以我想发布这个。

我能够使用CFSockets设置我的守护程序和代理之间的通信,它没有我以前所想的那么糟糕。我按照以下分步说明操作:
https://developer.apple.com/library/mac/#documentation/NetworkingInternet/Conceptual/NetworkingTopics/Articles/UsingSocketsandSocketStreams.html (编写基于TCP的服务器)。

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).

您可能还可以尝试使用纯BSD套接字。有一个简单的示例: http://www.minek.com/files/unix_examples/ poll.html (虽然我没有尝试过)。

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).

祝你好运。

这篇关于OS X - 启动守护程序和启动代理之间的通信的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆