diff options
-rw-r--r-- | meta/lib/oe/terminal.py | 23 | ||||
-rwxr-xr-x | scripts/oe-gnome-terminal-phonehome | 10 |
2 files changed, 32 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 | ||
71 | class Mate(XTerminal): | 92 | class Mate(XTerminal): |
72 | command = 'mate-terminal -t "{title}" -x {command}' | 93 | command = 'mate-terminal -t "{title}" -x {command}' |
diff --git a/scripts/oe-gnome-terminal-phonehome b/scripts/oe-gnome-terminal-phonehome new file mode 100755 index 0000000000..e02354883a --- /dev/null +++ b/scripts/oe-gnome-terminal-phonehome | |||
@@ -0,0 +1,10 @@ | |||
1 | #!/bin/sh | ||
2 | # | ||
3 | # Gnome terminal won't tell us which PID a given command is run as | ||
4 | # or allow a single instance so we can't tell when it completes. | ||
5 | # This allows us to figure out the PID of the target so we can tell | ||
6 | # when its done. | ||
7 | # | ||
8 | echo $$ > $1 | ||
9 | shift | ||
10 | exec $@ | ||