aboutsummaryrefslogtreecommitdiff
path: root/driver-ti.c
diff options
context:
space:
mode:
Diffstat (limited to 'driver-ti.c')
-rw-r--r--driver-ti.c23
1 files changed, 2 insertions, 21 deletions
diff --git a/driver-ti.c b/driver-ti.c
index ce2a820..ee9104a 100644
--- a/driver-ti.c
+++ b/driver-ti.c
@@ -15,8 +15,6 @@
#include <stdio.h>
#include <string.h>
#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
/* To be efficient at lookups, we store the byte sequence => keyinfo mapping
* in a trie. This avoids a slow linear search through a flat list of
@@ -309,25 +307,16 @@ static int
start_driver (termkey_t *tk, void *info)
{
termkey_ti_t *ti = info;
- struct stat statbuf;
char *start_string = ti->start_string;
size_t len;
- if (tk->fd == -1 || !start_string)
+ if (tk->fd == -1 || !isatty (tk->fd) || !start_string)
return 1;
/* The terminfo database will contain keys in application cursor key mode.
* We may need to enable that mode
*/
- // FIXME: isatty() should suffice
- /* There's no point trying to write() to a pipe */
- if (fstat (tk->fd, &statbuf) == -1)
- return 0;
-
- if (S_ISFIFO (statbuf.st_mode))
- return 1;
-
// Can't call putp or tputs because they suck and don't give us fd control
len = strlen (start_string);
while (len)
@@ -346,18 +335,10 @@ static int
stop_driver (termkey_t *tk, void *info)
{
termkey_ti_t *ti = info;
- struct stat statbuf;
char *stop_string = ti->stop_string;
size_t len;
- if (tk->fd == -1 || !stop_string)
- return 1;
-
- /* There's no point trying to write() to a pipe */
- if (fstat (tk->fd, &statbuf) == -1)
- return 0;
-
- if (S_ISFIFO (statbuf.st_mode))
+ if (tk->fd == -1 || !isatty (tk->fd) || !stop_string)
return 1;
/* The terminfo database will contain keys in application cursor key mode.