Corelib: check if TIOCNOTTY is supported before using it

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 <thiago.macieira@intel.com>
This commit is contained in:
Carlo Bramini 2025-01-01 17:38:03 +01:00
parent 48573ddda3
commit 1008628b34

View File

@ -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.