From 1008628b34cdb92bbf63d657053b55c3de2af70e Mon Sep 17 00:00:00 2001 From: Carlo Bramini Date: Wed, 1 Jan 2025 17:38:03 +0100 Subject: [PATCH] Corelib: check if TIOCNOTTY is supported before using it MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On CYGWIN, the build process fails at this point: qtbase/src/corelib/io/qprocess_unix.cpp:878:31: error: ‘TIOCNOTTY’ was not declared in this scope; did you mean ‘TIOCSCTTY’? 878 | int r = ioctl(fd, TIOCNOTTY); | ^~~~~~~~~ | TIOCSCTTY TIOCNOTTY is not defined on CYGWIN because we don't need to do anything more to disconnect our controlling terminal. According to the man page for termio(7) from a SYSV 3.2 system, it says: "The first terminal file opened by the process group leader of a terminal file not already associated with a process group becomes the control terminal for that process group. The control terminal plays a special role in handling quit and interrupt signals, as discussed below. The control terminal is inherited by a child process during a fork(2). A process can break this association by changing its process group using setpgrp(2)." Change-Id: I2719f91d814ce7b71598853c4b1c70a99a4af33a Reviewed-by: Thiago Macieira --- src/corelib/io/qprocess_unix.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 0ea9d2a85ea..60ccf273374 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -881,6 +881,7 @@ static const char *applyProcessParameters(const QProcess::UnixProcessParameters // Disconnect from the controlling TTY. This probably won't fail. Must be // done after the session settings from above. if (params.flags.testFlag(QProcess::UnixProcessFlag::DisconnectControllingTerminal)) { +#ifdef TIOCNOTTY if (int fd = open(_PATH_TTY, O_RDONLY | O_NOCTTY); fd >= 0) { // we still have a controlling TTY; give it up int r = ioctl(fd, TIOCNOTTY); @@ -891,6 +892,7 @@ static const char *applyProcessParameters(const QProcess::UnixProcessParameters return "ioctl"; } } +#endif } // Disable core dumps near the end. This isn't expected to fail.