6 void __procfdname(char *, unsigned);
8 int ttyname_r(int fd, char *name, size_t size)
10 char procname[sizeof "/proc/self/fd/" + 3*sizeof(int) + 2];
13 if (!isatty(fd)) return ENOTTY;
15 __procfdname(procname, fd);
16 l = readlink(procname, name, size);
18 if (l < 0) return errno;
19 else if (l == size) return ERANGE;