diff options
-rw-r--r-- | src/unistd/ttyname.c | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/unistd/ttyname.c b/src/unistd/ttyname.c index 471d3ad7..dfb560bc 100644 --- a/src/unistd/ttyname.c +++ b/src/unistd/ttyname.c @@ -5,27 +5,25 @@ #include "_unistd.h" #include "_syscall.h" -#ifndef PATH_MAX -#define PATH_MAX _POSIX_PATH_MAX -#endif - #ifndef readlink -#define readlink(_path, _buf, _bufsiz) __syscall(__syscall_lookup(readlink), _path, _buf, _bufsiz, 0, 0, 0) +#define readlink(_path, _buf, _bufsiz) __scall3(readlink, _path, _buf, _bufsiz) #endif char *ttyname(int fildes) { char path[PATH_MAX + 1]; + static char __ttyname[PATH_MAX + 1]; if (!isatty(fildes)) { return NULL; } sprintf(path, "/proc/self/fd/%d", fildes); - if (readlink(path, __unistd.ttyname, sizeof(__unistd.ttyname)) == -1) { + if (readlink(path, __ttyname, sizeof(__ttyname)) == -1) { return NULL; } - return __unistd.ttyname; + + return __ttyname; } /* POSIX(1) |