Merge lp:~bregma/unity/lp-1324114 into lp:unity

Proposed by Stephen M. Webb
Status: Merged
Approved by: Marco Trevisan (Treviño)
Approved revision: no longer in the source branch.
Merged at revision: 3831
Proposed branch: lp:~bregma/unity/lp-1324114
Merge into: lp:unity
Diff against target: 32 lines (+14/-1)
1 file modified
tools/unity.cmake (+14/-1)
To merge this branch: bzr merge lp:~bregma/unity/lp-1324114
Reviewer Review Type Date Requested Status
Marco Trevisan (Treviño) Approve
PS Jenkins bot (community) continuous-integration Approve
Review via email: mp+223665@code.launchpad.net

Commit message

reduce the scope of the kill command when restarting compiz

Description of the change

Reduced the scope of the kill command when restarting compiz so that only those on the same $DISPLAY get clobbered.

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) wrote :

Looks fine, I would use a regex to avoid other false positive checks btw

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Marco Trevisan (Treviño) (3v1n0) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'tools/unity.cmake'
2--- tools/unity.cmake 2014-03-22 17:05:04 +0000
3+++ tools/unity.cmake 2014-07-08 14:29:23 +0000
4@@ -22,6 +22,7 @@
5 import glob
6 from optparse import OptionParser
7 import os
8+import re
9 import shutil
10 import signal
11 import subprocess
12@@ -100,7 +101,19 @@
13
14 # kill a previous compiz if was there (this is a hack as compiz can
15 # sometimes get stuck and not exit on --replace)
16- subprocess.call (["pkill", "-9", "compiz"])
17+ display = "DISPLAY=" + os.environ["DISPLAY"]
18+ pids = [pid for pid in os.listdir("/proc") if pid.isdigit()]
19+
20+ for pid in pids:
21+ try:
22+ pid_path = os.path.join("/proc", pid)
23+ cmdline = open(os.path.join(pid_path, "cmdline"), "rb").read()
24+ if re.match(r"^compiz\b", cmdline):
25+ compiz_env = open(os.path.join(pid_path, "environ"), "rb").read()
26+ if display in compiz_env:
27+ subprocess.call (["kill", "-9", pid])
28+ except IOError:
29+ continue
30
31 # shell = True as it's the simpest way to | tee.
32 # In this case, we need a string and not a list