PKGBUILDs/core/klibc-kbd/no-isatty.patch

59 lines
1.3 KiB
Diff

From 92dc27dd57c83e9e2c798bda41ec111d26e1e3e2 Mon Sep 17 00:00:00 2001
From: Roman Kyrylych <roman@archlinux.org>
Date: Sat, 15 Mar 2008 18:57:04 +0200
Subject: [PATCH] Do not use isatty() when built with klibc
Signed-off-by: Roman Kyrylych <roman@archlinux.org>
---
src/getfd.c | 6 ++++++
1 files changed, 6 insertions(+), 0 deletions(-)
diff --git a/src/getfd.c b/src/getfd.c
index 7f6d70e..3cef522 100644
--- a/src/getfd.c
+++ b/src/getfd.c
@@ -16,6 +16,7 @@
* if someone else used X (which does a chown on /dev/console).
*/
+#ifndef __klibc__
static int
is_a_console(int fd) {
char arg;
@@ -25,6 +26,7 @@ is_a_console(int fd) {
&& ioctl(fd, KDGKBTYPE, &arg) == 0
&& ((arg == KB_101) || (arg == KB_84)));
}
+#endif
static int
open_a_console(const char *fnam) {
@@ -41,10 +43,12 @@ open_a_console(const char *fnam) {
fd = open(fnam, O_RDONLY);
if (fd < 0)
return -1;
+ #ifndef __klibc__
if (!is_a_console(fd)) {
close(fd);
return -1;
}
+ #endif
return fd;
}
@@ -80,9 +84,11 @@ int getfd(const char *fnam) {
if (fd >= 0)
return fd;
+ #ifndef __klibc__
for (fd = 0; fd < 3; fd++)
if (is_a_console(fd))
return fd;
+ #endif
fprintf(stderr,
_("Couldnt get a file descriptor referring to the console\n"));
--
1.5.3.7