From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bFk1g-0002Iu-97 for qemu-devel@nongnu.org; Wed, 22 Jun 2016 11:25:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bFk1Z-0004IR-D2 for qemu-devel@nongnu.org; Wed, 22 Jun 2016 11:25:11 -0400 References: <20160622125320.31279-1-famz@redhat.com> <20160622125320.31279-2-famz@redhat.com> <576AACE8.5090506@redhat.com> From: Eric Blake Message-ID: <576AADC9.1070208@redhat.com> Date: Wed, 22 Jun 2016 09:24:57 -0600 MIME-Version: 1.0 In-Reply-To: <576AACE8.5090506@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="DJpDRhqastpvRv3ctdIUp0QDMARsoKbiu" Subject: Re: [Qemu-devel] [PATCH v2 1/2] osdep: Introduce qemu_dup List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --DJpDRhqastpvRv3ctdIUp0QDMARsoKbiu From: Eric Blake To: Fam Zheng , qemu-devel@nongnu.org Cc: Kevin Wolf , qemu-block@nongnu.org, Max Reitz Message-ID: <576AADC9.1070208@redhat.com> Subject: Re: [Qemu-devel] [PATCH v2 1/2] osdep: Introduce qemu_dup References: <20160622125320.31279-1-famz@redhat.com> <20160622125320.31279-2-famz@redhat.com> <576AACE8.5090506@redhat.com> In-Reply-To: <576AACE8.5090506@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 06/22/2016 09:21 AM, Eric Blake wrote: > On 06/22/2016 06:53 AM, Fam Zheng wrote: >> And use it in qemu_dup_flags. >> >> Signed-off-by: Fam Zheng >> --- >> include/qemu/osdep.h | 3 +++ >> util/osdep.c | 23 +++++++++++++++-------- >> 2 files changed, 18 insertions(+), 8 deletions(-) >> >=20 >> +int qemu_dup(int fd) >> +{ >> + int ret; >> +#ifdef F_DUPFD_CLOEXEC >> + ret =3D fcntl(fd, F_DUPFD_CLOEXEC, 0); >> +#else >> + ret =3D dup(fd); >> + if (ret !=3D -1) { >> + qemu_set_cloexec(ret); >> + } >=20 > Is it any more efficient to try and use dup3(fd, 0, O_CLOEXEC), or are > we assuming that F_DUPFD_CLOEXEC and dup3() are only likely to both be > present or absent? Scratch that. dup3() has different semantics than dup()/fcntl(F_DUPFD) (overwrite destination fd vs. next available fd). So no change to your code after all. >=20 > Otherwise, > Reviewed-by: Eric Blake >=20 --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --DJpDRhqastpvRv3ctdIUp0QDMARsoKbiu Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJXaq3JAAoJEKeha0olJ0Nq2pEH/25ftDBO/hg4BGtBtTs4Fi1Y OmVt3Y8cNDNuPk+NXDSjRBxbk2lJ82hbeRxcLTDCAQPz/vfTuS170sUN0DXbd6Lt wJDxEowJQtxKLEaujLmu4UaOpuIwFEiGrAGBkXu/RpF2tJthp0rrdq002jhLTMhT LDQjaNZmFUiiahNQrnpygV3HJxNrbyhNagWJT8JA2bBzz7xPJ6UVxvkRizhPRpEK iBhA12mX/sNaX5SZpVTu870nUHB95P9orTEax36elmU+8Ss81Pg+eclksB8Urau0 rSU3OYjzx2UHAIZ75Ylq4kxczfpGL4CXXPfhONKXa0npGCcFvLMIeYqr4nbcnas= =yMNg -----END PGP SIGNATURE----- --DJpDRhqastpvRv3ctdIUp0QDMARsoKbiu--