]> code.delx.au - pulseaudio/blobdiff - polyp/socket-server.c
make use F_CLOEXEC wherever useful
[pulseaudio] / polyp / socket-server.c
index f01e417c4cf134182faba86fce5d88de6136c852..131339eda929d95381b750f91067489aa947cbb0 100644 (file)
@@ -38,6 +38,7 @@
 #include "socket-server.h"
 #include "socket-util.h"
 #include "xmalloc.h"
+#include "util.h"
 
 struct pa_socket_server {
     int ref;
@@ -65,6 +66,8 @@ static void callback(struct pa_mainloop_api *mainloop, struct pa_io_event *e, in
         goto finish;
     }
 
+    pa_fd_set_cloexec(nfd, 1);
+    
     if (!s->on_connection) {
         close(nfd);
         goto finish;
@@ -122,6 +125,8 @@ struct pa_socket_server* pa_socket_server_new_unix(struct pa_mainloop_api *m, co
         goto fail;
     }
 
+    pa_fd_set_cloexec(fd, 1);
+
     sa.sun_family = AF_LOCAL;
     strncpy(sa.sun_path, filename, sizeof(sa.sun_path)-1);
     sa.sun_path[sizeof(sa.sun_path) - 1] = 0;
@@ -166,6 +171,8 @@ struct pa_socket_server* pa_socket_server_new_ipv4(struct pa_mainloop_api *m, ui
         goto fail;
     }
 
+    pa_fd_set_cloexec(fd, 1);
+
     if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)) < 0)
         fprintf(stderr, "setsockopt(): %s\n", strerror(errno));