1
0
mirror of git://git.suckless.org/sbase synced 2024-12-25 16:32:37 +00:00
sbase/tty.c

25 lines
342 B
C
Raw Normal View History

2011-06-02 20:15:35 +00:00
/* See LICENSE file for copyright and license details. */
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
int
main(void)
{
char *tty;
if((tty = ttyname(STDIN_FILENO))) {
puts(tty);
return 0;
}
else if(errno == ENOTTY) {
puts("not a tty");
return 1;
}
else {
perror("ttyname");
return 2;
}
}