Use tcgetattr() instead of ioctl() for portability

This commit is contained in:
Joel Rosdahl 2010-07-16 17:45:54 +02:00
parent 755eaafad9
commit 977253bc89
2 changed files with 3 additions and 4 deletions

View File

@ -172,7 +172,7 @@ AC_HEADER_TIME
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(ctype.h pwd.h stdlib.h string.h strings.h sys/time.h sys/mman.h)
AC_CHECK_HEADERS(sys/ioctl.h termios.h)
AC_CHECK_HEADERS(termios.h)
AC_CHECK_FUNCS(asprintf)
AC_CHECK_FUNCS(gethostname)

View File

@ -19,10 +19,9 @@
#include "ccache.h"
#include "framework.h"
#include <stdio.h>
#if defined(HAVE_TERMIOS_H) && defined(HAVE_SYS_IOCTL_H)
#if defined(HAVE_TERMIOS_H)
#define USE_COLOR
#include <termios.h>
#include <sys/ioctl.h>
#endif
static unsigned passed_asserts;
@ -48,7 +47,7 @@ is_tty(int fd)
{
#ifdef USE_COLOR
struct termios t;
return ioctl(fd, TCGETS, &t) == 0;
return tcgetattr(fd, &t) == 0;
#else
(void)fd;
return 0;