如何在 X11 中跟踪相关窗口? [英] How do I keep track of related windows in X11?
问题描述
不幸的是,我的问题并不像跟踪同一进程创建的两个窗口那么简单.
Unfortunately, my question is not as simple as keeping track of two windows created by the same process.
这是我所拥有的:
- Jack 和 Jim 两个用户远程登录到同一个 Unix 系统并运行 X 服务器
- Jack 运行了一个应用程序AwesomeApp",它在 X 窗口中打开了一个 GUI
- Jim 运行此应用程序的另一个实例,打开他自己的 GUI 窗口
- 现在,Jack 运行一个主管应用程序,该应用程序将与拥有第一个窗口的进程(例如AwesomeApp")进行通信,因为它是AwesomeApp"的 HIS 实例
- 他的主管实例如何找到AwesomeApp"窗口的哪个实例是他自己的?
Aaaahhhh...在每个用户的基础上查找它是可行的.只要我告诉用户他们不能从两个不同的地方使用相同的用户帐户登录.
Aaaahhhh...looking it up on a per-user basis yes that could work. As long as I tell the users that they cannot log in with the same user account from two different places.
推荐答案
您可以使用 pgrep 获取 Jack 的 AwesomeApp 实例的进程 ID:
You can use pgrep to get the process ID of Jack's instance of AwesomeApp:
pgrep -u Jack AwesomeApp
因此,如果您从 shell 脚本启动主管应用程序,您可以执行以下操作:
So if you launch the supervisor application from a shell script, you could do something like the following:
AWESOME_ID=`pgrep -u $USER AwesomeApp 2>/dev/null`
# run the supervisor application and pass the process id as the argument
supervisor $AWESOME_ID
或者,如果您不想使用 pgrep 或 ps 等外部程序,您可以随时尝试直接在 /proc 中查找流程.
Alternatively, if you don't want to use external programs like pgrep or ps, you could always try looking for the process in /proc directly.
这篇关于如何在 X11 中跟踪相关窗口?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!