[libc][unistd] 完善isatty()

This commit is contained in:
Meco Man 2021-04-26 14:31:31 +08:00
parent f90c522308
commit 19347ed454
2 changed files with 22 additions and 5 deletions

View File

@ -15,18 +15,29 @@
#ifdef RT_USING_POSIX_TERMIOS #ifdef RT_USING_POSIX_TERMIOS
#include "termios.h" #include "termios.h"
int isatty(int fd) int isatty(int fd)
{ {
struct termios ts; struct termios ts;
return(tcgetattr(fd,&ts) != -1);/*true if no error (is a tty)*/ return(tcgetattr(fd, &ts) != -1); /*true if no error (is a tty)*/
}
#else
int isatty(int fd)
{
if (fd >=0 && fd < 3)
{
return 1;
}
else
{
return 0;
}
} }
RTM_EXPORT(isatty);
#endif #endif
RTM_EXPORT(isatty);
char *ttyname(int fd) char *ttyname(int fd)
{ {
return "/dev/tty0"; /*TODO: need to add more specific*/ return "/dev/tty"; /*TODO: need to add more specific*/
} }
RTM_EXPORT(ttyname); RTM_EXPORT(ttyname);
@ -50,11 +61,16 @@ int usleep(useconds_t usec)
} }
RTM_EXPORT(usleep); RTM_EXPORT(usleep);
pid_t getpid(void) pid_t gettid(void)
{ {
/*TODO*/ /*TODO*/
return 0; return 0;
} }
pid_t getpid(void)
{
return gettid();
}
RTM_EXPORT(getpid); RTM_EXPORT(getpid);
pid_t getppid(void) pid_t getppid(void)

View File

@ -98,6 +98,7 @@ _isatty_r(struct _reent *ptr, int fd)
return 0; return 0;
} }
} }
int int
_kill_r(struct _reent *ptr, int pid, int sig) _kill_r(struct _reent *ptr, int pid, int sig)
{ {