From: Michael Jumper Date: Tue, 12 Jul 2011 21:43:57 +0000 (-0700) Subject: If fork()ing, parent process must close child's socket fd. Child close() is not suffi... X-Git-Url: http://git.alex.org.uk If fork()ing, parent process must close child's socket fd. Child close() is not sufficient as both parent and child have a reference to the same socket fd, and fd will never be free'd if close() is not called from both processes. --- diff --git a/src/daemon.c b/src/daemon.c index c4f4661..0920f44 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -302,6 +302,11 @@ int main(int argc, char* argv[]) { return 0; } + /* If parent, close reference to child's descriptor */ + else if (CLOSE_SOCKET(connected_socket_fd) < 0) { + guac_log_error("Error closing daemon reference to child descriptor: %s", lasterror()); + } + #else if (guac_thread_create(&thread, start_client_thread, (void*) data))