cunistd.c 682 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) 2006-2022, RT-Thread Development Team
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. *
  6. * Change Logs:
  7. * Date Author Notes
  8. * 2023-08-16 Meco Man first version
  9. */
  10. #include <rtthread.h>
  11. #include <unistd.h>
  12. #include <sys/errno.h>
  13. int isatty(int fd)
  14. {
  15. #if defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE)
  16. if(fd == STDOUT_FILENO || fd == STDERR_FILENO)
  17. {
  18. return 1;
  19. }
  20. #endif /* defined(RT_USING_CONSOLE) && defined(RT_USING_DEVICE) */
  21. #ifdef RT_USING_POSIX_STDIO
  22. if(fd == STDIN_FILENO)
  23. {
  24. return 1;
  25. }
  26. #endif /* RT_USING_POSIX_STDIO */
  27. rt_set_errno(ENOTTY);
  28. return 0;
  29. }
  30. RTM_EXPORT(isatty);