#include #include int main(void) { char *tty = ttyname(STDIN_FILENO); if (tty) puts(tty); else puts("not a tty"); return tty == NULL; }