1
0
mirror of git://git.suckless.org/sbase synced 2024-12-25 00:12:42 +00:00
sbase/tty.c
Connor Lane Smith 894b42a885 add tty
2011-06-02 21:15:35 +01:00

25 lines
342 B
C

/* 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;
}
}