File 90_close_socket_on_exec.patch of Package uim

Description: plug leak to unclosed socket after exec() in client by setting CLOEXEC
Author: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Bug-Debian: https://bugs.debian.org/787208
Forwarded: https://github.com/uim/uim/pull/56
Last-Update: 2015-05-29

Index: uim-1.8.6/uim/uim-helper-client.c
===================================================================
--- uim-1.8.6.orig/uim/uim-helper-client.c
+++ uim-1.8.6/uim/uim-helper-client.c
@@ -44,6 +44,7 @@
 #include <errno.h>
 #include <sys/stat.h>
 #include <unistd.h>
+#include <fcntl.h>
 
 #ifdef HAVE_STRINGS_H
 #include <strings.h>
@@ -93,6 +94,7 @@ int uim_helper_init_client_fd(void (*dis
     perror("fail to create socket");
     goto error;
   }
+  fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
   
 #ifdef LOCAL_CREDS /* for NetBSD */
   /* Set the socket to receive credentials on the next message */
Index: uim-1.8.6/uim/socket.c
===================================================================
--- uim-1.8.6.orig/uim/socket.c
+++ uim-1.8.6/uim/socket.c
@@ -278,7 +278,10 @@ c_freeaddrinfo(uim_lisp addrinfo_)
 static uim_lisp
 c_socket(uim_lisp domain_, uim_lisp type_, uim_lisp protocol_)
 {
-  return MAKE_INT(socket(C_INT(domain_), C_INT(type_), C_INT(protocol_)));
+  int fd = socket(C_INT(domain_), C_INT(type_), C_INT(protocol_));
+  if (fd != -1)
+    fcntl(fd, F_SETFD, fcntl(fd, F_GETFD, 0) | FD_CLOEXEC);
+  return MAKE_INT(fd);
 }
 
 static uim_lisp