1 #include <unistd.h> 2 #include <errno.h> 3 #include <limits.h> 4 #include <unsupported_api.h> 5 ttyname(int fd)6char *ttyname(int fd) 7 { 8 static char buf[TTY_NAME_MAX]; 9 int result; 10 unsupported_api(__FUNCTION__); 11 if ((result = ttyname_r(fd, buf, sizeof buf))) { 12 errno = result; 13 return NULL; 14 } 15 return buf; 16 } 17