On 02/13/2018 09:31 AM, Richard Henderson wrote:
I wonder if there are guest programs that make assumptions about
file descriptor numbers such that it would be worthwhile dup2'ing
the interp_dirfd away from the presumably low number fd it will
get by default into something larger...
Hmm. Using dup2(probe, probe) to test if the new (high) fd itself has not been
fcntl(F_DUPFD[_CLOEXEC]) is smarter than dup2/3, if you plan on
atomically guaranteeing a dup to a not-in-use fd.
Will dup'ing to a high fd violate assumptions of programs that assume
that open() and friends favor the next available fd by default, rather
than having a gap? (Probably not, but skipping fds is not usual, so
it's worth asking.)
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org