[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Printing to terminal/standard output problem
- From: Francesco Abbate <francesco.bbt@...>
- Date: Sun, 20 Nov 2011 17:20:44 +0100
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)
end
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.
Francesco