[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH V2 03/22] oslib: qemu_clr_cloexec
From: |
Steve Sistare |
Subject: |
[PATCH V2 03/22] oslib: qemu_clr_cloexec |
Date: |
Tue, 5 Jan 2021 07:41:51 -0800 |
Define qemu_clr_cloexec, analogous to qemu_set_cloexec.
Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>
Signed-off-by: Steve Sistare <steven.sistare@oracle.com>
---
include/qemu/osdep.h | 1 +
util/oslib-posix.c | 9 +++++++++
util/oslib-win32.c | 4 ++++
3 files changed, 14 insertions(+)
diff --git a/include/qemu/osdep.h b/include/qemu/osdep.h
index 20872e7..d7d67f2 100644
--- a/include/qemu/osdep.h
+++ b/include/qemu/osdep.h
@@ -554,6 +554,7 @@ static inline void qemu_timersub(const struct timeval *val1,
#endif
void qemu_set_cloexec(int fd);
+void qemu_clr_cloexec(int fd);
/* Starting on QEMU 2.5, qemu_hw_version() returns "2.5+" by default
* instead of QEMU_VERSION, so setting hw_version on MachineClass
diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index ad8001a..9e3b477 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -314,6 +314,15 @@ void qemu_set_cloexec(int fd)
assert(f != -1);
}
+void qemu_clr_cloexec(int fd)
+{
+ int f;
+ f = fcntl(fd, F_GETFD);
+ assert(f != -1);
+ f = fcntl(fd, F_SETFD, f & ~FD_CLOEXEC);
+ assert(f != -1);
+}
+
/*
* Creates a pipe with FD_CLOEXEC set on both file descriptors
*/
diff --git a/util/oslib-win32.c b/util/oslib-win32.c
index c654daf..42eb2cc 100644
--- a/util/oslib-win32.c
+++ b/util/oslib-win32.c
@@ -254,6 +254,10 @@ void qemu_set_cloexec(int fd)
{
}
+void qemu_clr_cloexec(int fd)
+{
+}
+
/* Offset between 1/1/1601 and 1/1/1970 in 100 nanosec units */
#define _W32_FT_OFFSET (116444736000000000ULL)
--
1.8.3.1
- [PATCH V2 00/22] Live Update, Steve Sistare, 2021/01/05
- [PATCH V2 03/22] oslib: qemu_clr_cloexec,
Steve Sistare <=
- [PATCH V2 06/22] vl: add helper to request re-exec, Steve Sistare, 2021/01/05
- [PATCH V2 04/22] util: env var helpers, Steve Sistare, 2021/01/05
- [PATCH V2 08/22] cpr: QMP interfaces, Steve Sistare, 2021/01/05
- [PATCH V2 09/22] cpr: HMP interfaces, Steve Sistare, 2021/01/05
- [PATCH V2 10/22] pci: export functions for cpr, Steve Sistare, 2021/01/05
- [PATCH V2 07/22] cpr, Steve Sistare, 2021/01/05
- [PATCH V2 05/22] vl: memfd-alloc option, Steve Sistare, 2021/01/05