diff options
author | Skip Montanaro <skip@pobox.com> | 2000-07-19 14:34:14 (GMT) |
---|---|---|
committer | Skip Montanaro <skip@pobox.com> | 2000-07-19 14:34:14 (GMT) |
commit | 1517d842b6d1dc7d762a007c028bb3dc23f6d383 (patch) | |
tree | df11ba7de2af53f5a9fee4bfc374f92097342bdd /Modules | |
parent | b1aac244d0baa549f59746254851e4561cfb7a10 (diff) | |
download | cpython-1517d842b6d1dc7d762a007c028bb3dc23f6d383.zip cpython-1517d842b6d1dc7d762a007c028bb3dc23f6d383.tar.gz cpython-1517d842b6d1dc7d762a007c028bb3dc23f6d383.tar.bz2 |
new method isatty from Thomas Wouters
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/posixmodule.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index 2cf9881..24f1dc2 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -3244,6 +3244,21 @@ posix_fdopen(PyObject *self, PyObject *args) return f; } +static char posix_isatty__doc__[] = +"isatty(fd) -> Boolean\n\ +Return true if the file descriptor 'fd' is an open file descriptor\n\ +connected to a terminal."; + +static PyObject * +posix_isatty(self, args) + PyObject *self; + PyObject *args; +{ + int fd; + if (!PyArg_ParseTuple(args, "i:isatty", &fd)) + return NULL; + return Py_BuildValue("i", isatty(fd)); +} #ifdef HAVE_PIPE static char posix_pipe__doc__[] = @@ -5038,6 +5053,7 @@ static PyMethodDef posix_methods[] = { {"write", posix_write, METH_VARARGS, posix_write__doc__}, {"fstat", posix_fstat, METH_VARARGS, posix_fstat__doc__}, {"fdopen", posix_fdopen, METH_VARARGS, posix_fdopen__doc__}, + {"isatty", posix_isatty, METH_VARARGS, posix_isatty__doc__}, #ifdef HAVE_PIPE {"pipe", posix_pipe, METH_VARARGS, posix_pipe__doc__}, #endif |