Advertisement
Guest User

Untitled

a guest
Oct 10th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. #include <fcntl.h>
  2. #include <glob.h>
  3. #include <termios.h>
  4. #include <unistd.h>
  5.  
  6. #include <stdio.h>
  7.  
  8. int main() {
  9. glob_t globbuf;
  10. char ** ttyp;
  11.  
  12. glob("/dev/tty*", GLOB_NOSORT, 0, &globbuf);
  13. ttyp = globbuf.gl_pathv;
  14.  
  15. do {
  16. struct termios options;
  17. int fd = open(*ttyp, O_RDWR | O_NOCTTY | O_NDELAY);
  18. if (fd == -1) continue;
  19. tcgetattr(fd, &options);
  20. if (!(options.c_lflag & (ISIG | IEXTEN)))
  21. printf("%s\n", *ttyp);
  22. close(fd);
  23. } while (*++ttyp);
  24.  
  25. globfree(&globbuf);
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement