add tty
This commit is contained in:
24
tty.c
Normal file
24
tty.c
Normal 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;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user