From 63a88fde89d92f2aee5062a99bd5c8357d18867c Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 30 May 2017 10:44:11 -0600 Subject: [PATCH] Use /proc/self consistently on Linux. As far as I know, only AIX doesn't support /proc/self. --HG-- branch : 1.8 --- src/ttyname.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/ttyname.c b/src/ttyname.c index 355c88606..ac632a185 100644 --- a/src/ttyname.c +++ b/src/ttyname.c @@ -451,7 +451,8 @@ done: char * get_process_ttyname(char *name, size_t namelen) { - char path[PATH_MAX], *line = NULL; + const char path[] = "/proc/self/stat"; + char *line = NULL; char *ret = NULL; size_t linesize = 0; int serrno = errno; @@ -459,8 +460,7 @@ get_process_ttyname(char *name, size_t namelen) FILE *fp; debug_decl(get_process_ttyname, SUDO_DEBUG_UTIL) - /* Try to determine the tty from tty_nr in /proc/pid/stat. */ - snprintf(path, sizeof(path), "/proc/%u/stat", (unsigned int)getpid()); + /* Try to determine the tty from tty_nr in /proc/self/stat. */ if ((fp = fopen(path, "r")) != NULL) { len = getline(&line, &linesize, fp); fclose(fp); -- 2.40.0