Commit 8826c7ff authored by Adriaan de Groot's avatar Adriaan de Groot 💬
Browse files

Fix virtual_terminal.cpp build on FreeBSD

- need to shuffle some Linux includes behind an ifdef, and some
  FreeBSD ones as well
- FreeBSD has no notion of major device numbers anymore, so the
  isTty() function can't really tell. Just ignore the check --
  I'm assuming the somewhat-standard isatty() doesn't do what
  is wanted, since otherwise it would be used.
parent 33aff4fc
......@@ -26,16 +26,21 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include <QDebug>
#include <QSocketNotifier>
// linux
#ifdef Q_OS_LINUX
#include <linux/major.h>
#include <linux/kd.h>
#include <linux/vt.h>
#include <sys/sysmacros.h>
#endif
#ifdef Q_OS_FREEBSD
#include <sys/consio.h>
#endif
// system
#include <fcntl.h>
#include <unistd.h>
#include <sys/ioctl.h>
#include <sys/signalfd.h>
#include <sys/stat.h>
#include <sys/sysmacros.h>
// c++
#include <csignal>
......@@ -81,9 +86,14 @@ static bool isTty(int fd)
if (fstat(fd, &st) == -1) {
return false;
}
#ifdef Q_OS_LINUX
// Not a TTY device or weird vt number, skip it
if (major(st.st_rdev) != TTY_MAJOR || minor (st.st_rdev) <= 0 || minor(st.st_rdev) >= 64) {
return false;
}
#endif
// FreeBSD doesn't have a notion of major device number, so nothing
// to check. isatty() might not do the trick.
return true;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment