qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Richard Henderson <rth@twiddle.net>,
	Peter Maydell <peter.maydell@linaro.org>,
	Richard Henderson <richard.henderson@linaro.org>
Cc: QEMU Developers <qemu-devel@nongnu.org>
Subject: Re: [Qemu-devel] [PATCH] linux-user: Use *at functions to implement interp_prefix
Date: Tue, 13 Feb 2018 10:38:18 -0600	[thread overview]
Message-ID: <aff1a8c0-4e99-b52e-f933-fdc900bd91fd@redhat.com> (raw)
In-Reply-To: <18af5519-95cd-f00e-1915-75183e94eb38@twiddle.net>

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
> allocated?

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

  reply	other threads:[~2018-02-13 16:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-28 22:15 [Qemu-devel] [PATCH] linux-user: Use *at functions to implement interp_prefix Richard Henderson
2018-01-28 22:20 ` no-reply
2018-02-13 12:12 ` Peter Maydell
2018-02-13 15:31   ` Richard Henderson
2018-02-13 16:38     ` Eric Blake [this message]
2018-02-13 16:43       ` Peter Maydell
2018-02-13 16:50         ` Peter Maydell
2018-02-13 17:22           ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aff1a8c0-4e99-b52e-f933-fdc900bd91fd@redhat.com \
    --to=eblake@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=rth@twiddle.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).