Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fcntl.h>
- #include <glob.h>
- #include <termios.h>
- #include <unistd.h>
- #include <stdio.h>
- int main() {
- glob_t globbuf;
- char ** ttyp;
- glob("/dev/tty*", GLOB_NOSORT, 0, &globbuf);
- ttyp = globbuf.gl_pathv;
- do {
- struct termios options;
- int fd = open(*ttyp, O_RDWR | O_NOCTTY | O_NDELAY);
- if (fd == -1) continue;
- tcgetattr(fd, &options);
- if (!(options.c_lflag & (ISIG | IEXTEN)))
- printf("%s\n", *ttyp);
- close(fd);
- } while (*++ttyp);
- globfree(&globbuf);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement