From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ian Campbell Subject: Re: [PATCH v4 09/29] tools/libxl: Fix libxl__carefd_opened() to be more useful with an invalid fd Date: Tue, 14 Jul 2015 15:08:34 +0100 Message-ID: <1436882914.25044.78.camel@citrix.com> References: <1436871584-6522-1-git-send-email-andrew.cooper3@citrix.com> <1436871584-6522-10-git-send-email-andrew.cooper3@citrix.com> <21925.4384.683619.778535@mariner.uk.xensource.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <21925.4384.683619.778535@mariner.uk.xensource.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org To: Ian Jackson Cc: Andrew Cooper , Wei Liu , Xen-devel List-Id: xen-devel@lists.xenproject.org On Tue, 2015-07-14 at 14:39 +0100, Ian Jackson wrote: > Andrew Cooper writes ("[PATCH v4 09/29] tools/libxl: Fix libxl__carefd_opened() to be more useful with an invalid fd"): > > In the case that fd is -1, preserve errno and don't attempt to set > > CLOEXEC. > > > > Note that the implementation can still fail, as it ignores fcntl() > > errors and may not set CLOEXEC properly. Update the documentation > > accordingly until it is fixed. > > Acked-by: Ian Jackson > > > Fixing the fnctl() error issue involves more TUITs than I currently > > have. > > I think that if the fcntl set cloexec fails, we should probably abort > the program. Ian C, would that be OK with you ? If so then the > patch to fix this is trivial. http://pubs.opengroup.org/onlinepubs/9699919799/functions/fcntl.html suggests the only relevant failures which can occur for setting cloexec would be EBADF or EINVAL, both of which would be program errors in this code path and not external factors or due to other threads. So I think an abort would be ok in this instance. Ian.