From 2629296c257b6d74e86e9f9139b04ba5e27b68d8 Mon Sep 17 00:00:00 2001 From: Ryan Dahl Date: Thu, 21 Oct 2010 12:34:37 -0700 Subject: [PATCH] Add isatty for isaacs --- src/node_stdio.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/node_stdio.cc b/src/node_stdio.cc index 5e09a84496..659675816a 100644 --- a/src/node_stdio.cc +++ b/src/node_stdio.cc @@ -104,6 +104,18 @@ static Handle GetRows (const Arguments& args) { return scope.Close(Integer::NewFromUnsigned(ws.ws_row)); } + +static Handle IsATTY (const Arguments& args) { + HandleScope scope; + + int fd = args[0]->IntegerValue(); + + int r = isatty(fd); + + return scope.Close(r ? True() : False()); +} + + /* STDERR IS ALWAY SYNC ALWAYS UTF8 */ static Handle WriteError (const Arguments& args) @@ -219,6 +231,7 @@ void Stdio::Initialize(v8::Handle target) { NODE_SET_METHOD(target, "setRawMode", SetRawMode); NODE_SET_METHOD(target, "getColumns", GetColumns); NODE_SET_METHOD(target, "getRows", GetRows); + NODE_SET_METHOD(target, "isatty", IsATTY); struct sigaction sa = {0}; sa.sa_handler = HandleSIGCONT;