unistd.c 768 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2006-2021, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2020-09-01 Meco Man first Version
  9. * 2021-02-12 Meco Man move all functions located in <pthread_sleep.c> to this file
  10. */
  11. #include <rtthread.h>
  12. #include <unistd.h>
  13. #ifdef RT_USING_POSIX_TERMIOS
  14. #include "termios.h"
  15. int isatty(int fd)
  16. {
  17. struct termios ts;
  18. return(tcgetattr(fd, &ts) != -1); /*true if no error (is a tty)*/
  19. }
  20. #else
  21. int isatty(int fd)
  22. {
  23. if (fd >=0 && fd < 3)
  24. {
  25. return 1;
  26. }
  27. else
  28. {
  29. return 0;
  30. }
  31. }
  32. #endif
  33. RTM_EXPORT(isatty);
  34. char *ttyname(int fd)
  35. {
  36. return "/dev/tty"; /* TODO: need to add more specific */
  37. }
  38. RTM_EXPORT(ttyname);