qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 1/2] qemu/osdep: fix current process fds path for other OSes


From: Clément Léger
Subject: [PATCH 1/2] qemu/osdep: fix current process fds path for other OSes
Date: Fri, 30 Aug 2024 13:14:49 +0200

While Linux and Solaris uses /proc/self/fd, other OSes (MacOS,
FreeBSD) uses /dev/fd. In order to support theses OSes, use /dev/fd as
a fallback.

Fixes: 4ec5ebea078e ("qemu/osdep: Move close_all_open_fds() to oslib-posix")
Reported-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Clément Léger <cleger@rivosinc.com>
---
 util/oslib-posix.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/util/oslib-posix.c b/util/oslib-posix.c
index 11b35e48fb..901dcccd73 100644
--- a/util/oslib-posix.c
+++ b/util/oslib-posix.c
@@ -814,8 +814,13 @@ static bool qemu_close_all_open_fd_proc(const int *skip, 
unsigned int nskip)
     int fd, dfd;
     DIR *dir;
     unsigned int skip_start = 0, skip_end = nskip;
+#if defined(CONFIG_LINUX) || defined(CONFIG_SOLARIS)
+    const char *self_fd = "/proc/self/fd";
+#else
+    const char *self_fd = "/dev/fd";
+#endif
 
-    dir = opendir("/proc/self/fd");
+    dir = opendir(self_fd);
     if (!dir) {
         /* If /proc is not mounted, there is nothing that can be done. */
         return false;
-- 
2.45.2




reply via email to

[Prev in Thread] Current Thread [Next in Thread]