tty.c 454 B

123456789101112131415161718
  1. /* vim: tabstop=4 shiftwidth=4 noexpandtab
  2. * This file is part of ToaruOS and is released under the terms
  3. * of the NCSA / University of Illinois License - see LICENSE.md
  4. * Copyright (C) 2018 K. Lange
  5. *
  6. * tty - print terminal name
  7. */
  8. #include <stdio.h>
  9. #include <unistd.h>
  10. int main(int argc, char * argv[]) {
  11. if (!isatty(STDIN_FILENO)) {
  12. fprintf(stdout, "not a tty\n");
  13. return 1;
  14. }
  15. fprintf(stdout,"%s\n",ttyname(STDIN_FILENO));
  16. return 0;
  17. }