]> git.sesse.net Git - cubemap/blobdiff - udpinput.cpp
Create $(libdir) on make install.
[cubemap] / udpinput.cpp
index 4b421a3e4fe90c91732a7a24c53adc476175fd7d..824c3bcf856146d23adb4dbf80b13f89325bb2cb 100644 (file)
@@ -1,5 +1,6 @@
 #include <assert.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <poll.h>
 #include <stddef.h>
 #include <stdlib.h>
@@ -120,6 +121,10 @@ UDPInput::UDPInput(const InputProto &serialized)
        : url(serialized.url()),
          sock(serialized.sock())
 {
+       // Set back the close-on-exec flag for the socket.
+       // (This can't leak into a child, since we haven't been started yet.)
+       fcntl(sock, F_SETFD, FD_CLOEXEC);
+
        // Should be verified by the caller.
        string protocol;
        bool ok = parse_url(url, &protocol, &user, &host, &port, &path);
@@ -139,6 +144,10 @@ UDPInput::UDPInput(const InputProto &serialized)
 
 InputProto UDPInput::serialize() const
 {
+       // Unset the close-on-exec flag for the socket.
+       // (This can't leak into a child, since there's only one thread left.)
+       fcntl(sock, F_SETFD, 0);
+
        InputProto serialized;
        serialized.set_url(url);
        serialized.set_sock(sock);