summaryrefslogtreecommitdiffstats
path: root/meta/lib
diff options
context:
space:
mode:
authorRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-06 17:08:57 +0100
committerRichard Purdie <richard.purdie@linuxfoundation.org>2016-07-08 10:50:18 +0100
commitc706bfbabbf9f7caf2cf509eb91381fb49aa44cb (patch)
tree7b43b206da86104e415676fb5eb5e4a5adfffbba /meta/lib
parent9df3cdf42d8c1216682f497f0b166a43ef9f4184 (diff)
downloadpoky-c706bfbabbf9f7caf2cf509eb91381fb49aa44cb.tar.gz
terminal: Fix gnome-terminal to work with recent versions
Currently gnome-terminal just returns straight away, opening a terminal in a new separate process we have no insight into. For patch resolution, this leads to spawning many different terminal windows, for pydevshell, it just flashes a window up and then closes. We need to block until the command completes but gnome-terminal gives us no way to do this. We therefore write the pid to a file using a "phonehome" wrapper script, then monitor the pid until it exits. [YOCTO #7254] (also fixing do_devpyshell) (From OE-Core rev: 76e8ab47c936674b8bb9bf1c48de53b30f5bf74a) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib')
-rw-r--r--meta/lib/oe/terminal.py23
1 files changed, 22 insertions, 1 deletions
diff --git a/meta/lib/oe/terminal.py b/meta/lib/oe/terminal.py
index 7f4458ea33..4a5ab1abba 100644
--- a/meta/lib/oe/terminal.py
+++ b/meta/lib/oe/terminal.py
@@ -66,7 +66,28 @@ class Gnome(XTerminal):
66 if vernum and LooseVersion(vernum) >= '3.10': 66 if vernum and LooseVersion(vernum) >= '3.10':
67 logger.debug(1, 'Gnome-Terminal 3.10 or later does not support --disable-factory') 67 logger.debug(1, 'Gnome-Terminal 3.10 or later does not support --disable-factory')
68 self.command = 'gnome-terminal -t "{title}" -x {command}' 68 self.command = 'gnome-terminal -t "{title}" -x {command}'
69 XTerminal.__init__(self, sh_cmd, title, env, d) 69
70 # We need to know when the command completes but gnome-terminal gives us no way
71 # to do this. We therefore write the pid to a file using a "phonehome" wrapper
72 # script, then monitor the pid until it exits. Thanks gnome!
73
74 import tempfile
75 pidfile = tempfile.NamedTemporaryFile(delete = False).name
76 try:
77 sh_cmd = "oe-gnome-terminal-phonehome " + pidfile + " " + sh_cmd
78 XTerminal.__init__(self, sh_cmd, title, env, d)
79 while os.stat(pidfile).st_size <= 0:
80 continue
81 with open(pidfile, "r") as f:
82 pid = int(f.readline())
83 finally:
84 os.unlink(pidfile)
85
86 while True:
87 try:
88 os.kill(pid, 0)
89 except OSError:
90 return
70 91
71class Mate(XTerminal): 92class Mate(XTerminal):
72 command = 'mate-terminal -t "{title}" -x {command}' 93 command = 'mate-terminal -t "{title}" -x {command}'