mirror of
https://github.com/mapbox/tippecanoe.git
synced 2025-03-25 13:17:38 +00:00
Warn about broken pipes in filters instead of exiting abruptly
This commit is contained in:
parent
6a5461763c
commit
71ac6596af
3
main.cpp
3
main.cpp
@ -24,6 +24,7 @@
|
||||
#include <sys/resource.h>
|
||||
#include <pthread.h>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <set>
|
||||
@ -2207,6 +2208,8 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
signal(SIGPIPE, SIG_IGN);
|
||||
|
||||
files_open_at_start = open("/dev/null", O_RDONLY | O_CLOEXEC);
|
||||
if (files_open_at_start < 0) {
|
||||
perror("open /dev/null");
|
||||
|
16
plugin.cpp
16
plugin.cpp
@ -12,6 +12,7 @@
|
||||
#include <pthread.h>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <cmath>
|
||||
#include <sys/types.h>
|
||||
#include <sys/wait.h>
|
||||
@ -42,8 +43,6 @@ struct writer_arg {
|
||||
void *run_writer(void *a) {
|
||||
writer_arg *wa = (writer_arg *) a;
|
||||
|
||||
// XXX worry about SIGPIPE?
|
||||
|
||||
FILE *fp = fdopen(wa->write_to, "w");
|
||||
if (fp == NULL) {
|
||||
perror("fdopen (pipe writer)");
|
||||
@ -53,8 +52,16 @@ void *run_writer(void *a) {
|
||||
layer_to_geojson(fp, *(wa->layer), wa->z, wa->x, wa->y, false, false);
|
||||
|
||||
if (fclose(fp) != 0) {
|
||||
perror("fclose output to filter");
|
||||
exit(EXIT_FAILURE);
|
||||
if (errno == EPIPE) {
|
||||
static bool warned = false;
|
||||
if (!warned) {
|
||||
fprintf(stderr, "Warning: broken pipe in postfilter\n");
|
||||
warned = true;
|
||||
}
|
||||
} else {
|
||||
perror("fclose output to filter");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@ -382,7 +389,6 @@ serial_feature parse_feature(json_pull *jp, int z, unsigned x, unsigned y, std::
|
||||
}
|
||||
|
||||
auto fk = layermap.find(layername);
|
||||
fprintf(stderr, "assign layer %zu\n", fk->second.id);
|
||||
sf.layer = fk->second.id;
|
||||
|
||||
if (z < fk->second.minzoom) {
|
||||
|
12
tile.cpp
12
tile.cpp
@ -1378,8 +1378,16 @@ void *run_prefilter(void *v) {
|
||||
}
|
||||
|
||||
if (fclose(rpa->prefilter_fp) != 0) {
|
||||
perror("fclose output to prefilter");
|
||||
exit(EXIT_FAILURE);
|
||||
if (errno == EPIPE) {
|
||||
static bool warned = false;
|
||||
if (!warned) {
|
||||
fprintf(stderr, "Warning: broken pipe in prefilter\n");
|
||||
warned = true;
|
||||
}
|
||||
} else {
|
||||
perror("fclose output to prefilter");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user