From: Anthony PERARD Date: Thu, 29 Sep 2011 15:06:02 +0000 (+0100) Subject: libxl: Introduce libxl__fd_set_cloexec X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~9850 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=acb8458e258a3f96785e0ff2cb021b1e4eb9d4bb;p=xen.git libxl: Introduce libxl__fd_set_cloexec Signed-off-by: Anthony PERARD Acked-by: Ian Jackson Committed-by: Ian Jackson --- diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c index e2592789ce..8f4678020f 100644 --- a/tools/libxl/libxl_internal.c +++ b/tools/libxl/libxl_internal.c @@ -242,3 +242,16 @@ int libxl__file_reference_unmap(libxl_file_reference *f) return ERROR_FAIL; } + +int libxl__fd_set_cloexec(int fd) +{ + int flags = 0; + + if ((flags = fcntl(fd, F_GETFD)) == -1) { + flags = 0; + } + if ((flags & FD_CLOEXEC)) { + return 0; + } + return fcntl(fd, F_SETFD, flags | FD_CLOEXEC); +} diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h index b431632103..1f78f9676a 100644 --- a/tools/libxl/libxl_internal.h +++ b/tools/libxl/libxl_internal.h @@ -384,6 +384,7 @@ _hidden int libxl__error_set(libxl__gc *gc, int code); _hidden int libxl__file_reference_map(libxl_file_reference *f); _hidden int libxl__file_reference_unmap(libxl_file_reference *f); +_hidden int libxl__fd_set_cloexec(int fd); _hidden int libxl__e820_alloc(libxl_ctx *ctx, uint32_t domid, libxl_domain_config *d_config);