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