调用 shell 脚本的应用程序的名称、PID

问题描述 投票:0回答:0

假设我们有一个名为 qBittorrent 的应用程序,它允许我们在完成 torrent 下载后运行 shell 脚本。在编写由 qBittorrent 调用的 shell 脚本时,我们意识到拥有调用 shell 脚本的应用程序的 PID 会很方便——在本例中为 qBittorrent。

如何在 bash、zsh 或 sh 中实现这一点?

我在这里阅读了一些提示并遇到了

$PPID
。在 macOS 上,这给了我
etc/launchd
而不是 qBittorrent。可能是 qBittorrent 正在调用
etc/launchd
来运行 shell 脚本……在那种情况下我需要返回父进程列表吗?

bash shell sh pid
© www.soinside.com 2019 - 2024. All rights reserved.