2020-12-12 06:33:20 +00:00
|
|
|
#define _POSIX_C_SOURCE 200809L
|
|
|
|
|
2020-02-12 05:30:50 +00:00
|
|
|
#include <unistd.h>
|
|
|
|
#include <string.h>
|
2020-12-12 06:33:20 +00:00
|
|
|
#include <stdio.h>
|
2020-02-12 05:30:50 +00:00
|
|
|
|
|
|
|
int main() {
|
2022-10-09 16:41:27 +00:00
|
|
|
/* Check if we're in a tty and, if so, print the devfile for it. */
|
2020-02-12 05:30:50 +00:00
|
|
|
if(isatty(fileno(stdin))) {
|
|
|
|
printf("%s\n", ttyname(0));
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
printf("not a tty\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|