 Ezhik
|
ezh@mobile ~ $ x-tile –without-panel
Traceback (most recent call last):
File “/usr/bin/x-tile”, line 203, in <module>
x.reload_windows_list()
File “/usr/share/x-tile/modules/core.py”, line 776, in reload_windows_list
self.store.load_model(self)
File “/usr/share/x-tile/modules/core.py”, line 100, in load_model
process_name = support.get_process_name(pid)
File “/usr/share/x-tile/modules/support.py”, line 246, in get_process_name
f = open(“/proc/%s/stat” % p)
IOError: [Errno 2] Нет такого файла или каталога: ‘/proc/10295/stat’
(translation is FILE NOT FOUND)
ezh@mobile ~ $ ps ax | grep 102
10298 ? Ss 0:00 gvim ENikiBeNiki.pl
why? IMHO answer is
part of wmctrl –help
-p Include PIDs in the window list. Very few
X applications support this feature.
more details:
_NET_WM_PID Support
The window manager has to set the _NET_WM_PID X-Window property of windows in order to work. E.g. kwin (and most modern window managers) do this, it seems there are cases where an application can screw this up. E.g. gvim forks so a shell from which it was started isn’t blocked. It seem to do this after the window is created and thus the _NET_WM_PID property contains an old PID that doesn’t exist any more. In the best case this program just fails, in the worst case another (wrong!) program has acquired this PID and gets copied instead. This way an other user might trick you into executing an application with your access rights!
patch:
diff -uNr old/core.py new/core.py
— old/core.py 2010-10-23 16:42:51.000000000 +0400
+++ new/core.py 2010-11-07 10:39:10.000000000 +0300
@@ -98,13 +98,22 @@
else:
pid = glob.ret_pointer[0]
process_name = support.get_process_name(pid)
- # filter based on process name – NB beppie I’d like something better for this but dont know what!
- self.process_picklist.add(process_name)
- if process_name not in self.process_blacklist: # user filter
- if process_name not in self.process_whitelist: # user flagged by default list
- self.liststore.append([False, client, title, pxb, False])
- else: self.liststore.append([True, client, title, pxb, False])
- rows_num += 1
+ if not process_name:
+ support.get_property(“WM_CLASS”, client, glob.str2_atom)
+ if bool(glob.ret_pointer)==False:
+ print “DEBUG warning WM_CLASS not set by application, skip window”, title
+ else:
+ wclass = ctypes.string_at(glob.ret_pointer)
+ process_name = wclass
+ print “DEBUG warning can’t get PID _NET_WM_PID failed, set process_name to”, wclass
+ if process_name:
+ # filter based on process name – NB beppie I’d like something better for this but dont know what!
+ self.process_picklist.add(process_name)
+ if process_name not in self.process_blacklist: # user filter
+ if process_name not in self.process_whitelist: # user flagged by default list
+ self.liststore.append([False, client, title, pxb, False])
+ else: self.liststore.append([True, client, title, pxb, False])
+ rows_num += 1
if rows_num == 2:
iter = self.liststore.get_iter_first()
while iter != None:
diff -uNr old/support.py new/support.py
— old/support.py 2010-10-20 20:48:39.000000000 +0400
+++ new/support.py 2010-11-07 10:22:54.000000000 +0300
@@ -242,7 +242,10 @@
try:
_exe = os.readlink(“/proc/%s/exe” % p)
except OSError:
- f = open(“/proc/%s/stat” % p)
+ try:
+ f = open(“/proc/%s/stat” % p)
+ except:
+ return;
try:
_exe = f.read().split(‘ ‘)[1].replace(‘(‘, ”).replace(‘)’, ”)
finally:
|
 Ezhik
|
diff -uNr old/core.py new/core.py
--- old/core.py 2010-10-23 16:42:51.000000000 +0400
+++ new/core.py 2010-11-07 10:39:10.000000000 +0300
@@ -98,13 +98,22 @@
else:
pid = glob.ret_pointer[0]
process_name = support.get_process_name(pid)
- # filter based on process name - NB beppie I'd like something better for this but dont know what!
- self.process_picklist.add(process_name)
- if process_name not in self.process_blacklist: # user filter
- if process_name not in self.process_whitelist: # user flagged by default list
- self.liststore.append([False, client, title, pxb, False])
- else: self.liststore.append([True, client, title, pxb, False])
- rows_num += 1
+ if not process_name:
+ support.get_property("WM_CLASS", client, glob.str2_atom)
+ if bool(glob.ret_pointer)==False:
+ print "DEBUG warning WM_CLASS not set by application, skip window", title
+ else:
+ wclass = ctypes.string_at(glob.ret_pointer)
+ process_name = wclass
+ print "DEBUG warning can't get PID _NET_WM_PID failed, set process_name to", wclass
+ if process_name:
+ # filter based on process name - NB beppie I'd like something better for this but dont know what!
+ self.process_picklist.add(process_name)
+ if process_name not in self.process_blacklist: # user filter
+ if process_name not in self.process_whitelist: # user flagged by default list
+ self.liststore.append([False, client, title, pxb, False])
+ else: self.liststore.append([True, client, title, pxb, False])
+ rows_num += 1
if rows_num == 2:
iter = self.liststore.get_iter_first()
while iter != None:
diff -uNr old/support.py new/support.py
--- old/support.py 2010-10-20 20:48:39.000000000 +0400
+++ new/support.py 2010-11-07 10:22:54.000000000 +0300
@@ -242,7 +242,10 @@
try:
_exe = os.readlink("/proc/%s/exe" % p)
except OSError:
- f = open("/proc/%s/stat" % p)
+ try:
+ f = open("/proc/%s/stat" % p)
+ except:
+ return;
try:
_exe = f.read().split(' ')[1].replace('(', '').replace(')', '')
finally:
|
 giuspen
|
Hello Ezhik,
Can you please send me a mail (you can find my email address clicking help–about) attaching the file(s) edited with the bug fixed so that I can easily compare using a graphic tool like meld or kdiff3?
it seems to me to understand that the problem is only in
f = open(“/proc/%s/stat” % p)
that I would simply replace with:
if os.path.isfile(“/proc/%s/stat” % p): f = open(“/proc/%s/stat” % p)
… and so on but please send me your edited files so I can see them clearly and discuss with you.
Thank you, regards,
Giuseppe.
|