]> git.proxmox.com Git - qemu.git/blobdiff - gdbstub.c
Don't leak file descriptors
[qemu.git] / gdbstub.c
index 055093f89ba39a04a0841eb3b932b84c659d265b..5a4f7d49b9fa43468c756698f7738abd0fabd1fe 100644 (file)
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -2356,6 +2356,9 @@ static void gdb_accept(void)
             perror("accept");
             return;
         } else if (fd >= 0) {
+#ifndef _WIN32
+            fcntl(fd, F_SETFD, FD_CLOEXEC);
+#endif
             break;
         }
     }
@@ -2385,6 +2388,9 @@ static int gdbserver_open(int port)
         perror("socket");
         return -1;
     }
+#ifndef _WIN32
+    fcntl(fd, F_SETFD, FD_CLOEXEC);
+#endif
 
     /* allow fast reuse */
     val = 1;