This is the mail archive of the
mailing list for the glibc project.
Re: [PATCH] support: Implement <support/descriptors.h> to track file descriptors
* Carlos O'Donell:
>> + DIR *fds = opendir ("/proc/self/fd");
> This makes support/descriptors.h dependent on /proc/self/fd?
> Can we exit UNSUPPORTED if it doesn't exist?
I think even Hurd has it.
I think it's a severe environmental problem if /proc does not exist, so
a failure is acceptable in this case.
>> + char path;
> Why not PATH_MAX?
It's not defined on Hurd.
> We should not stat a truncated fd path since it might match another fd?
> assert (strlen(e->d_name) < PATH_MAX);
We would get a compile-time failure with current GCC if truncation is
possible, I think:
>> + snprintf (path, sizeof (path), "/proc/self/fd/%ld", fd);
I could try to count more precisely how many bytes are actually needed,
but that seemed like a waste of mental resources. Should I use
xasprintf instead, to make clear that there is no truncation?