How do I keep track of related windows in X11?

ε祈祈猫儿з 提交于 2019-12-24 12:20:09

问题


Unfortunately, my question is not as simple as keeping track of two windows created by the same process.

Here is what I have:

  • Two users, Jack and Jim are remotely logged in to the same Unix system and run X servers
  • Jack runs an application, 'AwesomeApp', that opens a GUI in a X window
  • Jim runs another instance of this application, opening his own GUI window
  • Now, Jack runs a supervisor application that will communicate with the process owning the first window (eg 'AwesomeApp') because it's HIS instance of 'AwesomeApp'
  • How can his instance of the supervisor find which instance of 'AwesomeApp' window is his own?

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.


回答1:


You can use pgrep to get the process ID of Jack's instance of AwesomeApp:

pgrep -u Jack AwesomeApp


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


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.



来源:https://stackoverflow.com/questions/60967/how-do-i-keep-track-of-related-windows-in-x11

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!