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