XWindow: How to find my window PID… (command line arguments/working directory)?
Summary:
To find the PID of a running UNIX/XWindow process:
$ xprop _NET_WM_PID
If that fails:
$ ps -ww -fp <PID>
$ pwdx <PID>
Detailed explanation:
So How can you find the PID (not Window ID!) of a running UNIX/XWindow process?
Method 1 (simple):
$ xprop _NET_WM_PID
… and then click on window of interest and xprop will dump the info in the terminal where you started it.
If that can’t find the window in question try just ‘xprop’ without any arguments and try to figure out which process this is from the (extensive!) output.
Method 2 (more complicated):
Here’s a more complicated approach, for cases where xprop can not find the window PID. This usually happens with some XWin scripted apps (e.g based on Tcl/Tk (wish command)… like KDiff3 or gitk).
In reality, one classic scenario is:
– you want to close one of your terminal windows;
– you do a ‘ps’ to make sure you did not start from this terminal some other app which you do not want closed.
– ps tell you that you did actually start another app from it (e.g. kdiff3/wish). And shows you its PID of course – I am bring your attention to this fact because we will use this PID below.
– since you also e have, for example 2 other instances of kdiff3/wish open at the same time you are not sure which one you will be killing if you close this terminal.
So how can you figure out the PID of that ‘wish’ interpreter to decide whether it is safe to close the parent terminal window?
The solution I found working best for me is to either
a) use ‘ps’ to get the process command line arguments:
$ ps -ww -fp <PID>
– OR –
b) use the ‘pwdx’ command which will give the process’ working directory:
$ pwdx <PID>
Using a) or b) or both it is usually possible to figure out if this PID belongs to the process in question!
-
Categories
- Android Development
- Bash
- C programming
- dpkg/apt-get
- drupal
- Emacs
- Git
- Java
- Linux administration
- Linux device drivers
- Linux Gaming
- Linux kernel
- Linux Networking
- Linux on Windows
- Linux printing
- Linux sound and ALSA
- Package Managers
- Programming
- RPM
- Shell and environment
- Tips and tricks
- Uncategorized
- VirtualBox
- Virtualization
- web development
- wine
- WMaker
- Wordpress Tips
- X Window System
- XFCE
-
Articles
- August 2020
- August 2019
- May 2019
- July 2017
- February 2017
- January 2017
- November 2016
- October 2016
- September 2016
- August 2016
- July 2016
- June 2016
- April 2016
- March 2016
- December 2015
- November 2015
- September 2015
- June 2015
- May 2015
- April 2015
- March 2015
- February 2015
- January 2015
- December 2014
- October 2014
- February 2014
- January 2014
- November 2013
- October 2013
- June 2013
- April 2013
- March 2013
- February 2013
- January 2013
- December 2012
- October 2012
- August 2012
- July 2012
- June 2012
- May 2012
- April 2012
- March 2012
- February 2012
- September 2011
- August 2011
- June 2011
- May 2011
- April 2011
- March 2011
- February 2011
-
Meta
Cloud
audio bash boot compile C programming cups drupal emacs etc Fedora git grep how to httpd init kernel libc linux linux partition localtime login make mount mp3 mysql networking oracle package managers password phpMyAdmin programming rpm shell sql vbox version control system virtual box vm web server wordpress www xargs xfce xwin yum