diff options
author | Anthony PERARD <anthony.perard@citrix.com> | 2011-09-29 16:06:02 +0100 |
---|---|---|
committer | Anthony PERARD <anthony.perard@citrix.com> | 2011-09-29 16:06:02 +0100 |
commit | acb8458e258a3f96785e0ff2cb021b1e4eb9d4bb (patch) | |
tree | 607a2d584830d3c2cfc88a381eaa47a5ab4adcf3 /tools/libxl/libxl_internal.c | |
parent | 0c49cf7d494fc4e9b54a1d7a6ed03a09c01c3eae (diff) | |
download | xen-acb8458e258a3f96785e0ff2cb021b1e4eb9d4bb.tar.gz xen-acb8458e258a3f96785e0ff2cb021b1e4eb9d4bb.tar.bz2 xen-acb8458e258a3f96785e0ff2cb021b1e4eb9d4bb.zip |
libxl: Introduce libxl__fd_set_cloexec
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
Committed-by: Ian Jackson <ian.jackson@eu.citrix.com>
Diffstat (limited to 'tools/libxl/libxl_internal.c')
-rw-r--r-- | tools/libxl/libxl_internal.c | 13 |
1 files changed, 13 insertions, 0 deletions
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); +} |