better pid behaviour. we now in process list if pid contained in gajim.pid is still gajim. fixes #2165. (Linux only)
This commit is contained in:
parent
38fea2a389
commit
4d9e58a580
22
src/gajim.py
22
src/gajim.py
|
@ -145,7 +145,26 @@ pid_filename = gajimpaths['PID_FILE']
|
||||||
config_filename = gajimpaths['CONFIG_FILE']
|
config_filename = gajimpaths['CONFIG_FILE']
|
||||||
|
|
||||||
import dialogs
|
import dialogs
|
||||||
|
def pid_alive():
|
||||||
|
if os.name == 'nt':
|
||||||
if os.path.exists(pid_filename):
|
if os.path.exists(pid_filename):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
try:
|
||||||
|
pf = open(pid_filename)
|
||||||
|
pid = int(pf.read().strip())
|
||||||
|
pf.close()
|
||||||
|
f = open('/proc/%d/status'% pid)
|
||||||
|
n = f.readline()
|
||||||
|
f.close()
|
||||||
|
n = n.split()[1].strip()
|
||||||
|
if n == 'gajim':
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
return False
|
||||||
|
|
||||||
|
if pid_alive():
|
||||||
path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png')
|
path_to_file = os.path.join(gajim.DATA_DIR, 'pixmaps/gajim.png')
|
||||||
pix = gtk.gdk.pixbuf_new_from_file(path_to_file)
|
pix = gtk.gdk.pixbuf_new_from_file(path_to_file)
|
||||||
gtk.window_set_default_icon(pix) # set the icon to all newly opened wind
|
gtk.window_set_default_icon(pix) # set the icon to all newly opened wind
|
||||||
|
@ -168,7 +187,8 @@ pid_dir = os.path.dirname(pid_filename)
|
||||||
if not os.path.exists(pid_dir):
|
if not os.path.exists(pid_dir):
|
||||||
check_paths.create_path(pid_dir)
|
check_paths.create_path(pid_dir)
|
||||||
# Create pid file
|
# Create pid file
|
||||||
f = open(pid_filename, 'a')
|
f = open(pid_filename, 'w')
|
||||||
|
f.write(str(os.getpid()))
|
||||||
f.close()
|
f.close()
|
||||||
del pid_dir
|
del pid_dir
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue