diff options
author | Jakob Kaivo <jkk@ung.org> | 2020-09-25 13:19:21 -0400 |
---|---|---|
committer | Jakob Kaivo <jkk@ung.org> | 2020-09-25 13:19:21 -0400 |
commit | d66b80b2a194000dca0246a87e13921a8c9d3cfd (patch) | |
tree | 8f50faaf8a3af3081c2e538ac3e1384101519bba | |
parent | d92a2127be62f6503041d9e231de38713a9cb705 (diff) |
make __ttyname a function static variable
-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) |