lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I cannot resist to the temptations, this can be done so easily with
the FFI module :-)

local ffi = require('ffi')

ffi.cdef [[
  extern FILE *stdin;
  int isatty(int FILEDES);
  int fileno (FILE *STREAM);

function isatty()
   local fd = ffi.C.fileno(ffi.C.stdin)
   return ffi.C.isatty(fd)

Please note that the use of "fileno" can be avoided if you assume that
the file descriptor of stdin is 0. This is always true on linux.