fleshed out some tty stuff...

isatty() is fixed - altho this is basically academic since we don't have any
drivers for terminal devices written yet (but at least the code is ready when we do)

also, ctermid() is implemented - which is of no big consequence


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@3170 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Daniel Reinhold 2003-05-04 00:53:22 +00:00
parent 060ea25f57
commit 953aa0fc95

View File

@ -4,14 +4,44 @@
*/ */
#include <unistd.h>
#include <stdio.h> #include <stdio.h>
#include <string.h>
#include <unistd.h>
#include <termios.h>
/*
* isatty - is the given file descriptor bound to a terminal device?
*
* a simple call to fetch the terminal control attributes suffices
* (only a valid tty device will succeed)
*
*/
int int
isatty(int file) isatty(int fd)
{ {
// ToDo: please fix me! struct termios term;
return file < 3;
return (tcgetattr(fd, &term) == 0);
}
/*
* ctermid - return the name of the controlling terminal
*
* this is a totally useless function!
* (but kept for historical Posix compatibility)
* yes, it *always* returns "/dev/tty"
*
*/
char *
ctermid(char *s)
{
static char defaultBuffer[L_ctermid];
if (s == NULL)
s = defaultBuffer;
return strcpy(s, "/dev/tty");
} }