From aa849ed945cd46b1ba937b68ff918acd1c066f33 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Tue, 17 Dec 2013 07:38:20 -0700 Subject: [PATCH] Go back to using /proc/self/fd instead of /proc/$$/fd as only AIX lacks /proc/self and it has F_CLOSEM. --- compat/closefrom.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/compat/closefrom.c b/compat/closefrom.c index cb7fa8a5d..55a4d92c6 100644 --- a/compat/closefrom.c +++ b/compat/closefrom.c @@ -31,7 +31,6 @@ # endif #endif /* STDC_HEADERS */ #include -#include #ifdef HAVE_PSTAT_GETPROC # include # include @@ -121,14 +120,14 @@ closefrom(int lowfd) void closefrom(int lowfd) { - char path[PATH_MAX]; + const char *path; DIR *dirp; - /* Use /proc/$$/fd (or /dev/fd on FreeBSD) if it exists. */ + /* Use /proc/self/fd (or /dev/fd on FreeBSD) if it exists. */ # if defined(__FreeBSD__) || defined(__APPLE__) - snprintf(path, sizeof(path), "/dev/fd"); + path = "/dev/fd"; # else - snprintf(path, sizeof(path), "/proc/%u/fd", (unsigned int)getpid()); + path = "/proc/self/fd"; # endif if ((dirp = opendir(path)) != NULL) { struct dirent *dent;