]> git.sesse.net Git - cubemap/blobdiff - stream.cpp
Create $(libdir) on make install.
[cubemap] / stream.cpp
index 3ee1a434d2e6fe6c3cc73fcc84d89d860efd0f05..c79391a81990b2f94ddef1b460beb08b62de0274 100644 (file)
@@ -1,5 +1,6 @@
 #include <assert.h>
 #include <errno.h>
+#include <fcntl.h>
 #include <inttypes.h>
 #include <limits.h>
 #include <math.h>
@@ -67,6 +68,9 @@ Stream::Stream(const StreamProto &serialized, int data_fd)
                exit(1);
        }
 
+       // Set the close-on-exec parameter back on the backlog fd.
+       fcntl(data_fd, F_SETFD, FD_CLOEXEC);
+
        for (ssize_t point : serialized.suitable_starting_point()) {
                if (point == -1) {
                        // Can happen when upgrading from before 1.1.3,
@@ -103,6 +107,10 @@ StreamProto Stream::serialize()
        serialized.set_first_fragment_index(first_fragment_index);
        serialized.set_discontinuity_counter(discontinuity_counter);
 
+       // Unset the close-on-exec flag for the backlog fd.
+       // (This can't leak into a child, since there's only one thread left.)
+       fcntl(data_fd, F_SETFD, 0);
+
        serialized.set_url(url);
        data_fd = -1;
        return serialized;