From 4e9969998b3d385fc007fa5deba5f256aa7b2e95 Mon Sep 17 00:00:00 2001 From: Alexander Larsson <alexl@redhat.com> Date: Fri, 11 Dec 2015 15:56:06 +0100 Subject: [PATCH] Add glnx_steal_fd This is very useful in combination with glnx_close_fd https://bugzilla.gnome.org/show_bug.cgi?id=757611 --- glnx-local-alloc.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/glnx-local-alloc.h b/glnx-local-alloc.h index a193e603a..af5af4b88 100644 --- a/glnx-local-alloc.h +++ b/glnx-local-alloc.h @@ -211,4 +211,12 @@ glnx_cleanup_close_fdp (int *fdp) */ #define glnx_fd_close __attribute__((cleanup(glnx_cleanup_close_fdp))) +static inline int +glnx_steal_fd (int *fdp) +{ + int fd = *fdp; + *fdp = -1; + return fd; +} + G_END_DECLS -- GitLab