aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/oe/terminal.py
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:00 +0100
commit76e8ab47c936674b8bb9bf1c48de53b30f5bf74a (patch)
treedaffb48260aa88f16a3986fd0cac6aa30468c3b6 /meta/lib/oe/terminal.py
parent0c36984d4c501d12fa91cf7371511641585cc256 (diff)
downloadopenembedded-core-contrib-76e8ab47c936674b8bb9bf1c48de53b30f5bf74a.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) Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/lib/oe/terminal.py')
-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):
if vernum and LooseVersion(vernum) >= '3.10':
logger.debug(1, 'Gnome-Terminal 3.10 or later does not support --disable-factory')
self.command = 'gnome-terminal -t "{title}" -x {command}'
- XTerminal.__init__(self, sh_cmd, title, env, d)
+
+ # We need to know when 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. Thanks gnome!
+
+ import tempfile
+ pidfile = tempfile.NamedTemporaryFile(delete = False).name
+ try:
+ sh_cmd = "oe-gnome-terminal-phonehome " + pidfile + " " + sh_cmd
+ XTerminal.__init__(self, sh_cmd, title, env, d)
+ while os.stat(pidfile).st_size <= 0:
+ continue
+ with open(pidfile, "r") as f:
+ pid = int(f.readline())
+ finally:
+ os.unlink(pidfile)
+
+ while True:
+ try:
+ os.kill(pid, 0)
+ except OSError:
+ return
class Mate(XTerminal):
command = 'mate-terminal -t "{title}" -x {command}'
n241' href='#n241'>241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391