Keep from leaking other pipe file descriptors to unrelated children

This commit is contained in:
Eric Fischer 2016-12-07 11:25:42 -08:00
parent 58e268777c
commit a114a890d8

View File

@ -6,6 +6,7 @@
#include <map>
#include <pthread.h>
#include <unistd.h>
#include <fcntl.h>
#include <cmath>
#include <sys/types.h>
#include <sys/wait.h>
@ -281,6 +282,14 @@ mvt_layer filter_layer(const char *filter, mvt_layer &layer, unsigned z, unsigne
perror("close filter-side writer");
exit(EXIT_FAILURE);
}
if (fcntl(pipe_orig[1], F_SETFD, FD_CLOEXEC) != 0) {
perror("cloxec output to filter");
exit(EXIT_FAILURE);
}
if (fcntl(pipe_filtered[0], F_SETFD, FD_CLOEXEC) != 0) {
perror("cloxec input from filter");
exit(EXIT_FAILURE);
}
if (pthread_mutex_unlock(&pipe_lock) != 0) {
perror("pthread_mutex_unlock (pipe_lock)");