Skip to content
Snippets Groups Projects
Commit 4d9e58a5 authored by Yann Leboulanger's avatar Yann Leboulanger
Browse files

better pid behaviour. we now in process list if pid contained in gajim.pid is...

better pid behaviour. we now in process list if pid contained in gajim.pid is still gajim. fixes #2165. (Linux only)
parent 38fea2a3
No related branches found
No related tags found
No related merge requests found
......@@ -145,7 +145,26 @@
config_filename = gajimpaths['CONFIG_FILE']
import dialogs
if os.path.exists(pid_filename):
def pid_alive():
if os.name == 'nt':
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')
pix = gtk.gdk.pixbuf_new_from_file(path_to_file)
gtk.window_set_default_icon(pix) # set the icon to all newly opened wind
......@@ -168,7 +187,8 @@
if not os.path.exists(pid_dir):
check_paths.create_path(pid_dir)
# Create pid file
f = open(pid_filename, 'a')
f = open(pid_filename, 'w')
f.write(str(os.getpid()))
f.close()
del pid_dir
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment