Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I want to know the process ID of a particular window. I have seen and used the Force close panel applet, and I'd like something similar that would report me the process ID of the window I select.

If a tool for this purpose exists, that'd be great. Although, I am willing even to write a simple python script if it can be done.

Edit: In a more specific case, I want to get the process ID of a java swing window. (The xprop solution some answers suggest is not working).

Thanks.

share|improve this question
add comment

3 Answers

Use xprop _NET_WM_PID and click the window you want to query.

For instance, if you run it on a gnome-terminal:

 $ xprop _NET_WM_PID
 _NET_WM_PID(CARDINAL) = 2386
 $ pidof gnome-terminal
 2386
share|improve this answer
    
Thanks Egil, this seems to work for few windows, but I am trying on a java swing window, and the output comes as _NET_WM_PID: not found. Any idea? –  Shrikant Sharat Apr 21 '11 at 10:54
add comment
xprop _NET_WM_PID | cut -d' ' -f3

That will give you a target, click a window and it'll give you the PID.

I'm sending the output through cut (you could use awk '{ print $3 }' instead if you like) to clean it up so you could script it into something else, if you needed to.

share|improve this answer
    
Please see my comment on Egil's answer, this does not work for java swing windows. Any other way to do this? –  Shrikant Sharat Apr 21 '11 at 10:55
add comment

You could also open System Monitor. Switch to the Processes tab and look for your Java window.

share|improve this answer
    
All my java processes are listed as, well, java in that tab. How to know which process has opened which window? I couldn't find anything that shows this. –  Shrikant Sharat May 3 '11 at 6:27
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.