diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2017-09-09 12:06:59 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2017-09-09 12:06:59 -0400 |
commit | 500892f115aea9788da7649b59baaea38729aacf (patch) | |
tree | b4cdf6a5ad5348ab77e2164d125fc7fc726a04e3 /eval.c | |
parent | 55470cc8835ef774bf7defa9a4b319c8fa9d2f4b (diff) | |
download | bfs-500892f115aea9788da7649b59baaea38729aacf.tar.xz |
Try /proc/self/fd before /dev/fd
On Solaris, /proc/self/fd is dynamic while /dev/fd is static.
Diffstat (limited to 'eval.c')
-rw-r--r-- | eval.c | 9 |
1 files changed, 6 insertions, 3 deletions
@@ -1147,9 +1147,12 @@ static int infer_fdlimit(const struct cmdline *cmdline) { // 3 for std{in,out,err} int nopen = 3 + cmdline->nopen_files; - // Check /dev/fd for the current number of open fds, if possible (we may - // have inherited more than just the standard ones) - DIR *dir = opendir("/dev/fd"); + // Check /proc/self/fd for the current number of open fds, if possible + // (we may have inherited more than just the standard ones) + DIR *dir = opendir("/proc/self/fd"); + if (!dir) { + dir = opendir("/dev/fd"); + } if (dir) { // Account for 'dir' itself nopen = -1; |