changeset 11660 | c368b4f6ee04 |
parent 10925 | 6eb5d2bb11af |
child 12158 | 760dd1fc3dc1 |
--- a/util-src/pposix.c Sun Jul 04 02:33:15 2021 +0200 +++ b/util-src/pposix.c Sun Jul 04 15:11:07 2021 +0200 @@ -812,6 +812,13 @@ return 3; } +static int lc_isatty(lua_State *L) { + FILE *f = *(FILE **) luaL_checkudata(L, 1, LUA_FILEHANDLE); + const int fd = fileno(f); + lua_pushboolean(L, isatty(fd)); + return 1; +} + /* Register functions */ int luaopen_util_pposix(lua_State *L) { @@ -853,6 +860,8 @@ { "atomic_append", lc_atomic_append }, + { "isatty", lc_isatty }, + { NULL, NULL } };