qemu-devel
[Top][All Lists]
Advanced

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

Re: [Qemu-devel] [PATCH] Don't leak file descriptors


From: Nathan Froyd
Subject: Re: [Qemu-devel] [PATCH] Don't leak file descriptors
Date: Fri, 13 Nov 2009 07:41:18 -0800
User-agent: Mutt/1.5.13 (2006-08-11)

On Fri, Nov 13, 2009 at 04:17:16PM +0100, Kevin Wolf wrote:
> 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.
>
>> --- 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;
>          }
>      }

Why not just use the new accept wrapper here?

> @@ -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;

...and ditto for using the new wrapper here.

-Nathan




reply via email to

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