From: Daan De Meyer Date: Mon, 24 Apr 2023 13:10:07 +0000 (+0200) Subject: Use stderr to check for tty in foreground() X-Git-Tag: v15~204^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8dcc57ddcb81d6dc215ba367b284bf35f0743a4f;p=thirdparty%2Fmkosi.git Use stderr to check for tty in foreground() stdin/stdout might be redirected for other purposes, let's use stderr instead to detect if we're connected to a terminal. --- diff --git a/mkosi/run.py b/mkosi/run.py index e9dc20262..80328fff5 100644 --- a/mkosi/run.py +++ b/mkosi/run.py @@ -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)