diff options
author | William Jon McCann <mccann@jhu.edu> | 2007-08-14 11:50:54 -0400 |
---|---|---|
committer | William Jon McCann <mccann@jhu.edu> | 2007-08-14 11:50:54 -0400 |
commit | 383ea823871bf3768e85d1a3ca061e775c6aedf1 (patch) | |
tree | 3d5970d160777fecf4dc6a30998e3d8e13ad1793 /src/getfd.c | |
parent | e054c0f8b86f27f94d9316bac065a94081f4be32 (diff) |
add some solaris support
Based on a patch from Brian Cameron.
Diffstat (limited to 'src/getfd.c')
-rw-r--r-- | src/getfd.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/src/getfd.c b/src/getfd.c index 56c7dd7..8aa46ca 100644 --- a/src/getfd.c +++ b/src/getfd.c @@ -9,7 +9,10 @@ #include <stdio.h> #include <fcntl.h> #include <errno.h> +#include <unistd.h> +#ifdef __linux__ #include <linux/kd.h> +#endif #include <sys/ioctl.h> #ifdef HAVE_PATHS_H @@ -28,11 +31,18 @@ static int is_a_console (int fd) { char arg; + int kb_ok; arg = 0; - return (isatty (fd) - && ioctl (fd, KDGKBTYPE, &arg) == 0 - && ((arg == KB_101) || (arg == KB_84))); + +#ifdef __linux__ + kb_ok = (ioctl (fd, KDGKBTYPE, &arg) == 0 + && ((arg == KB_101) || (arg == KB_84))); +#else + kb_ok = 1; +#endif + + return (isatty (fd) && kb_ok); } static int @@ -59,17 +69,21 @@ int getfd (void) { int fd; +#ifdef _PATH_TTY fd = open_a_console (_PATH_TTY); if (fd >= 0) return fd; +#endif fd = open_a_console ("/dev/tty"); if (fd >= 0) return fd; +#ifdef _PATH_CONSOLE fd = open_a_console (_PATH_CONSOLE); if (fd >= 0) return fd; +#endif fd = open_a_console ("/dev/console"); if (fd >= 0) |