void VirtualTerminal::setup(int vtNr) { if (m_vt != -1) { return; } if (vtNr == -1) { // error condition return; } QString ttyName = QStringLiteral("/dev/tty%1").arg(vtNr); m_vt = open(ttyName.toUtf8().constData(), O_RDWR|O_CLOEXEC|O_NONBLOCK); if (m_vt < 0) { qCWarning(KWIN_CORE) << "Failed to open tty" << vtNr; return; } if (!isTty(m_vt)) { qCWarning(KWIN_CORE) << vtNr << " is no tty"; closeFd(); return; } if (ioctl(m_vt, KDSETMODE, KD_GRAPHICS) < 0) { qCWarning(KWIN_CORE()) << "Failed to set tty " << vtNr << " in graphics mode"; closeFd(); return; } if (!createSignalHandler()) { qCWarning(KWIN_CORE) << "Failed to create signalfd"; closeFd(); return; } vt_mode mode = { VT_PROCESS, 0, RELEASE_SIGNAL, ACQUISITION_SIGNAL, 0 }; if (ioctl(m_vt, VT_SETMODE, &mode) < 0) { qCWarning(KWIN_CORE) << "Failed to take over virtual terminal"; closeFd(); return; } m_vtNumber = vtNr; setActive(true); emit kwinApp()->virtualTerminalCreated(); }
FILESymbolizePrinter::FILESymbolizePrinter(FILE* file, int options) : SymbolizePrinter(options, isTty(options, fileno(file))), file_(file) { }
FDSymbolizePrinter::FDSymbolizePrinter(int fd, int options, size_t bufferSize) : SymbolizePrinter(options, isTty(options, fd)), fd_(fd), buffer_(bufferSize ? IOBuf::create(bufferSize) : nullptr) { }
OStreamSymbolizePrinter::OStreamSymbolizePrinter(std::ostream& out, int options) : SymbolizePrinter(options, isTty(options, getFD(out))), out_(out) { }