OS X上的守护程序与用户代理约定 [英] Daemon vs User Agent convention on OS X

查看:35
本文介绍了OS X上的守护程序与用户代理约定的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个应用程序,该应用程序将定期为用户从远程服务器下载文件.我想知道在OS X中我是否应该使用守护程序(即只要OS X已启动就可以运行)或用户代理(即只要特定用户已登录就可以运行).有约定吗?在考虑这一点时,有什么规则可以遵守吗?我当然不希望违反常规,最终让我的应用执行用户不希望做的事情.

I'm developing an app which will periodically download files from a remote server for a user. I'm wondering whether I should, in OS X parlance, use a daemon, i.e. it will run as long as OS X has been started, or a user agent, i.e. it will run as long as the particular user is logged in. Is there a convention? Are there any rules to abide by when thinking about this? I certainly don't want buck convention and end up having my app do something a user isn't expecting it to do.

此外,对于此类后台进程,似乎有一种惯例可以使应用程序显示在状态栏上.例如.状态栏中会显示我的计算机上的Google驱动器和Mozy,它们在后台监视更改并在后台上传.我应该对我的应用执行此操作吗?

Also, for such background processes, it seems like there might be a convention to have the app show up on the status bar. E.g. both Google drive and Mozy on my machine, which monitor for changes and upload in the background, both are represented in the status bar. Is this something I should do with my app?

推荐答案

绝对有一个约定, daemon 通常以root或特殊用户身份运行( mysql www ),然后以用户身份运行代理...

there is absolutely a convention, a daemon is typically run as root or a special user (mysql, www), and a Agent runs as the user...

它们的生存时间无关紧要,因为 daemon 可以像 httpd ftpd 等,或像使用辅助工具一样及时启动.

it doesn't matter with respect to how long they may live etc, as a daemon can either be long running like httpd, ftpd, etc, or launched just in time for use, as in a helper tool.

来自 man发射的人:

在启动的词典中,根据定义,守护程序"是系统范围的其中一项服务所有客户的实例.代理"是基于每个用户运行的服务.守护程序不应尝试显示UI或直接与用户的登录会话进行交互.任何涉及的工作与用户互动应通过代理完成.

In the launchd lexicon, a "daemon" is, by definition, a system-wide service of which there is one instance for all clients. An "agent" is a service that runs on a per-user basis. Daemons should not attempt to display UI or interact directly with a user's login session. Any and all work that involves interacting with a user should be done through agents.

因此您可能会与某种 IPC 混合使用,因为在备份守护程序中可能会将消息发送到状态栏应用程序,该应用程序以用户的代理身份运行.

so you may mix with some sort of IPC as in a backup daemon may send messages to a status bar app, which runs as and agent for your user.

这篇关于OS X上的守护程序与用户代理约定的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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