This commit is contained in:
Connor Lane Smith
2011-06-02 21:15:35 +01:00
parent 164e0c171f
commit 894b42a885
4 changed files with 39 additions and 2 deletions

24
tty.c Normal file
View File

@@ -0,0 +1,24 @@
/* 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;
}
}