MacOS可以启动守护程序呈现UI吗?

时间:2017-05-10 13:18:16

标签: macos cocoa macos-sierra launchd

根据Apple的文档,启动守护程序在系统上下文中运行,无法显示UI: Apple background process table Source

然而,作为测试,我在下面创建了一个简单的launchd plist指向我在Sierra上的MacOS应用程序,并且在执行sudo launchctl load /Library/LaunchDaemons/myapp.plist之后,该进程以root用户启动并且出现了主窗口。

是什么给出的?不应该以某种方式禁止用户界面吗?

<?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">
<plist version="1.0">
<dict>
<key>Label</key>
<string>myapp</string>
<key>ProgramArguments</key>
<array>
<string>myapp</string>
<string>--background</string>
</array>
<key>RunAtLoad</key>
<true/>
<key>StartInterval</key>
<integer>1</integer>
<key>KeepAlive</key>
<true/>
</dict>
</plist>

我在这里查看它的运行方式:

$ ps aux | grep myapp
dyoung           55912   0.0  0.0  2432804    800 s009  S+    9:14AM   
0:00.00 grep myapp
root             55176   0.0  0.1  2628312  23416   ??  Ss    8:43AM   0:01.04 /Users/dyoung/Library/Developer/Xcode/DerivedData/myapp-gsnwymohiqyegccsqziyfxdiztci/Build/Products/

0 个答案:

没有答案
相关问题