标签: launchd

iPhone应用程序在从Xcode启动时崩溃,但不是从iPhone启动

我有一个应用程序在iPhone上崩溃,但只有当它通过Xcode启动时.

我可以在iPhone控制台日志中看到应用程序收到内存警告,然后有一些奇怪的事件,如下所示:

Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Notice>: (UIKitApplication:com.mycom.myapp[0x3f60]) Bug: launchd_core_logic.c:3270 (24132):0
Sun Jul 11 00:03:43 Matts-iPhone com.apple.debugserver-48[5590] <Warning>: 1 [15d6/1403]: error: ::read ( 6, 0x3809f4, 1024 ) => -1 err = Bad file descriptor (0x00000009)
Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Notice>: (UIKitApplication:com.mycom.myapp[0x3f60]) Bug: launchd_core_logic.c:2688 (24132):10
Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Notice>: (UIKitApplication:com.mycom.myapp[0x3f60]) Working around 5020256. Assuming the job crashed.
Sun Jul 11 00:03:43 Matts-iPhone com.apple.launchd[1] (UIKitApplication:com.mycom.myapp[0x3f60][5591]) <Warning>: (UIKitApplication:com.mycom.myapp[0x3f60]) Job appears to have crashed: …
Run Code Online (Sandbox Code Playgroud)

memory iphone crash xcode launchd

4
推荐指数
1
解决办法
7135
查看次数

从 Mac OS X launchd 守护进程中执行

是否可以从 launchd 守护进程使用execve ?我想将进程制作成守护进程,然后使用 fork() 和 execve 启动多个子进程,但创建 launchd 守护进程的文档指出“调用 fork 后跟 exec”是不行的。这是否意味着我无法从守护进程创建子进程?

c++ macos daemon launchd execve

4
推荐指数
1
解决办法
1720
查看次数

"你好世界"推出了plist不工作

我在〜/ Library/LaunchAgents中有以下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">
<plist version="1.0">
  <dict>
    <key>Label</key>
    <string>com.yogapo.test_launchd</string>

    <key>Program</key>
    <string>. /Users/luke/dev/data_yogapo/script/test_launchd.sh</string>

    <key>StartInterval</key>
    <integer>10</integer>

    <key>RunAtLoad</key>
    <true/>
  </dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

test_launchd.sh文件包含以下内容:

#! /bin/bash 

echo "hello world from test_launchd.sh" >> /Users/luke/dev/data_yogapo/log/development.log
Run Code Online (Sandbox Code Playgroud)

当我手动运行test_launchd.sh时
. /Users/luke/dev/data_yogapo/script/test_launchd.sh ,结果与预期一致:该行出现在结尾处development.log

但是当我加载这个plist文件时,没有任何反应:

$ cd ~/Library/LaunchAgents
$ launchctl load com.yogapo.test_launchd.plist
$ launchctl list | grep yogapo
  -       1       com.yogapo.test_launchd
Run Code Online (Sandbox Code Playgroud)

我已经尝试过使用和不使用RunAtLoad键.我在这里以及互联网上的其他地方看过其他答案.我已经按照教程,并没有发生任何事情.任何帮助非常感谢 - 谢谢!

launchd plist

4
推荐指数
1
解决办法
8196
查看次数

使用Python启动最小的工作示例

我想用launchd每分钟运行一个python脚本.我的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">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.turtle.script.plist</string>
    <key>ProgramArguments</key>
    <array>
        <string>/usr/bin/python</string>
        <string>/Users/turtle/Desktop/turtle.py</string>
        <string>/Users/turtle/Desktop/data/data.txt</string>
    </array>
    <key>StartInterval</key>
    <integer>60</integer>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

这个plist文件看起来很好,因为我得到以下内容:

plutil -lint com.turtle.script.plist
com.turtle.script.plist: OK
Run Code Online (Sandbox Code Playgroud)

当我从命令行运行脚本时,脚本可以正常工作:

/usr/bin/python /Users/turtle/Desktop/turtle.py /Users/turtle/Desktop/data/data.txt
Run Code Online (Sandbox Code Playgroud)

我通过以下方式加载此plist:

   launchctl load -w -F com.turtle.script.plist
Run Code Online (Sandbox Code Playgroud)

我也尝试过:

sudo launchctl load -w -F com.turtle.script.plist
Run Code Online (Sandbox Code Playgroud)

我加载这个作业,python脚本应该写出一个文件到磁盘.但是没有生成任何文件.我检查了这份工作:

sudo launchctl list | grep com.turtle.script.plist
Run Code Online (Sandbox Code Playgroud)

输出是:

- 1 com.turtle.script.plist
Run Code Online (Sandbox Code Playgroud)

任何人都可以帮助解决问题吗?

python macos launchd

4
推荐指数
1
解决办法
8439
查看次数

如何使用 root 从 OSX 守护进程或代理启动 UI

我正在寻找一种在用户登录或系统启动时启动我的程序的方法。该程序需要具有 root 权限,并且需要在顶部菜单栏上显示一些 UI 内容。

我尝试使用 launchd 将其作为守护进程和代理启动。问题是守护进程不能有 UI。并且代理以用户身份运行,因此没有 root 权限。

我还尝试让守护进程使用setsid() 调用脚本,以使我的程序在不同的进程组中运行,但这也没有帮助。它只是无法显示任何 UI 内容。

我是 OSX 新手,确实需要一些帮助。

macos daemon launchd agent

4
推荐指数
1
解决办法
1726
查看次数

如何检查已启动的进程是否从shell脚本加载到MAC OS X中?

我有一个卸载的启动进程,我使用的命令是

launchctl unload /System/Library/LaunchDaemons/costomscript.plist

如果进程已加载,它可以正常工作.但是如果它没有加载并且我执行了命令,它会给出一条消息,说明没有加载这样的进程.所以我需要检查,如果当前加载了.plist文件,那么只有它应该被卸载,否则不会.

我怎么能做到这一点..请帮助.谢谢!!

macos launchd

4
推荐指数
1
解决办法
6050
查看次数

是否可以计算 launchd 的 ProgramArguments 数组中的表达式?

我有一个~/Library/LaunchAgents/setenv.JAVA_HOME.plist文件,其中包含/bin/launchctl如下调用:

<?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>setenv.JAVA_HOME</string>
    <key>ProgramArguments</key>
    <array>
        <string>/bin/launchctl</string>
        <string>setenv</string>
        <string>JAVA_HOME</string>
        <string>$(/usr/libexec/java_home -v1.8)</string>
    </array>
    <key>RunAtLoad</key>
    <true/>
    <key>ServiceIPC</key>
    <false/>
</dict>
</plist>
Run Code Online (Sandbox Code Playgroud)

问题是,$(/usr/libexec/java_home -v1.8)表达式没有被求值,而是JAVA_HOME环境变量被赋予了文字值$(/usr/libexec/java_home -v1.8)

问题是:是否可以编写我的 plist 文件,以便对表达式进行求值而不是将其视为文字值?如果是这样,怎么办?

macos launchd plist launchctl osx-elcapitan

4
推荐指数
1
解决办法
282
查看次数

launchd plist 中的相对路径

我目前正在使用 plist 来运行 shell 脚本。

 <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
        <plist version="1.0">
        <dict>
                <key>Label</key>
                <string>com.name.set</string>
                <key>Program</key>
                <string>/Users/username_here/Desktop/simple.sh</string>
                <key>RunAtLoad</key>
                <true/>
                <key>StartInterval</key>
                <integer>5</integer>
                <key>StandardErrorPath</key>
                <string>/tmp/com.name.example.stderr</string>
                <key>StandardOutPath</key>
                <string>/tmp/com.name.example.stdout</string>
        </dict>
        </plist>
Run Code Online (Sandbox Code Playgroud)

这有效!但是当我将程序名称更改为

<string>/Desktop/simple.sh</string>
Run Code Online (Sandbox Code Playgroud)

它不运行脚本。也~/Desktop/simple.sh不起作用。

有没有办法在不知道用户名和使用绝对路径的情况下运行脚本?

当我 tail launchd 时,我也收到此错误消息。

com.apple.xpc.launchd[1] (com.name.example[8178]): Service could not initialize: 14F27: xpcproxy + 13421 [1402][AD0301C4-D364-31CE-8BA7-B5DBECE64D0A]: 0x2
Run Code Online (Sandbox Code Playgroud)

谢谢!

path launchd plist

4
推荐指数
2
解决办法
1643
查看次数

获取“真实”父进程,以防使用 launchd 间接生成进程

我正在维护一个 OSX 工具,它显示选定进程的父树,从直接父进程到其最早的祖先(通常是 launchd)。

但是,如果检查的进程是使用诸如双击捆绑包图标之类的事件从 launchd 间接生成的,或者使用 command 从 bash 运行进程,则该进程链可能会中断open。在这些情况下,我希望看到其中一个bashfinder相应的。

也许 XPC 消息传递层就是答案,因为我假设这些事件通过此机制传递到 launchd。然而,其他可用的 OSX 框架总是受欢迎的。

编辑:

我知道,如果一个进程在运行时自行分离,我无法恢复它的 ppid,但我的目标是跟踪启动进程创建的调用者。

谢谢

c macos xpc launchd

4
推荐指数
1
解决办法
1595
查看次数

LaunchAgent 脚本无法写入外部驱动器

macOS Catalina

我有一个应该将文件写入外部驱动器的 python 脚本。如果我手动运行脚本,这会起作用。但是,如果该脚本是从 LaunchAgent bash 脚本启动的,则它无权这样做。

例如,简化的 python 脚本:

with open('/Volumes/nas_1/test/somefile.txt', 'a') as the_file:
                            the_file.write('Hello\n')
Run Code Online (Sandbox Code Playgroud)

LaunchAgent 启动的 Bash 脚本位于/Applications

#!/bin/bash

#Start test script only if it is not running
if [ "$(ps -ef | grep -v grep | grep python_test.py | wc -l)" -le 0 ]
then

echo "Python Test Starting"
/Users/admin-user/.venvs/test/bin/python /Users/admin-user/projects/test/scripts/python_test.py

else
 echo "Python Test Already Running"
fi
Run Code Online (Sandbox Code Playgroud)

plist 位于~/Library/LaunchAgents

<?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"> …
Run Code Online (Sandbox Code Playgroud)

python macos bash launchd macos-catalina

4
推荐指数
1
解决办法
861
查看次数

标签 统计

launchd ×10

macos ×7

plist ×3

daemon ×2

python ×2

agent ×1

bash ×1

c ×1

c++ ×1

crash ×1

execve ×1

iphone ×1

launchctl ×1

macos-catalina ×1

memory ×1

osx-elcapitan ×1

path ×1

xcode ×1

xpc ×1