]> git.ipfire.org Git - thirdparty/openembedded/openembedded-core-contrib.git/commitdiff
terminal: Show a warning when launched terminal quickly exits
authorMathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Sat, 15 Nov 2025 07:41:31 +0000 (08:41 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Mon, 17 Nov 2025 11:05:53 +0000 (11:05 +0000)
Terminals quitting in less than one second are likely the result of a
failure to execute the launched command: show a warning including the
command that was launched, so the user can try to debug this.

Signed-off-by: Mathieu Dubois-Briand <mathieu.dubois-briand@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/lib/oe/terminal.py

index 4412bc14c1d1ffc16e84f89313e9aed6694ab742..013d77581d5a1939efa28dc46f042df1b85156ee 100644 (file)
@@ -240,6 +240,7 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
     import tempfile
     import time
     pidfile = tempfile.NamedTemporaryFile(delete = False).name
+    start_time = None
     try:
         sh_cmd = bb.utils.which(os.getenv('PATH'), "oe-gnome-terminal-phonehome") + " " + pidfile + " " + sh_cmd
         pipe = terminal(sh_cmd, title, env, d)
@@ -249,6 +250,7 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
         if pipe.returncode != 0:
             raise ExecutionError(sh_cmd, pipe.returncode, output)
 
+        start_time = time.time()
         while os.stat(pidfile).st_size <= 0:
             time.sleep(0.01)
             continue
@@ -262,7 +264,10 @@ def spawn(name, sh_cmd, title=None, env=None, d=None):
             os.kill(pid, 0)
             time.sleep(0.1)
         except OSError:
-           return
+            if start_time and (time.time() - start_time < 1):
+                bb.warn("Terminal \"%s\" started but stopped after only %.2fs while running \"%s\""
+                        % (name, time.time() - start_time, sh_cmd))
+            return
 
 def check_tmux_version(desired):
     vernum = check_terminal_version("tmux")