]> git.ipfire.org Git - thirdparty/mkosi.git/commitdiff
Use stderr to check for tty in foreground()
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 24 Apr 2023 13:10:07 +0000 (15:10 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Mon, 24 Apr 2023 14:45:02 +0000 (16:45 +0200)
stdin/stdout might be redirected for other purposes, let's use stderr
instead to detect if we're connected to a terminal.

mkosi/run.py

index e9dc20262fb71ad4732f9aa09c236e96e90113bc..80328fff537523c2152b413f53375c03de82f1ad 100644 (file)
@@ -131,10 +131,11 @@ def foreground() -> None:
     If we're connected to a terminal, put the process in a new process group and make that the foreground
     process group so that only this process receives SIGINT.
     """
-    if sys.stdin.isatty():
+    STDERR_FILENO = 2
+    if os.isatty(STDERR_FILENO):
         os.setpgrp()
         old = signal.signal(signal.SIGTTOU, signal.SIG_IGN)
-        os.tcsetpgrp(0, os.getpgrp())
+        os.tcsetpgrp(STDERR_FILENO, os.getpgrp())
         signal.signal(signal.SIGTTOU, old)