From 40ff6d7e8dceca227e7f8a3e8e0d58b2c66d19b4 Mon Sep 17 00:00:00 2001 From: Kevin Wolf Date: Wed, 2 Dec 2009 12:24:42 +0100 Subject: Don't leak file descriptors We're leaking file descriptors to child processes. Set FD_CLOEXEC on file descriptors that don't need to be passed to children to stop this misbehaviour. Signed-off-by: Kevin Wolf Signed-off-by: Anthony Liguori --- gdbstub.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'gdbstub.c') diff --git a/gdbstub.c b/gdbstub.c index 055093f89..5a4f7d49b 100644 --- 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; -- cgit v1.2.3-65-gdbad