@cryptotaxi247 / netdata-1 / commits / 905a2dd54

Fix broken pipe ignoring in apps plugin (#8554)

* Fix broken pipe ignoring in apps plugin * Use poll instead of write

Vladimir Kobal committed Mar 31, 2020 at 23:01 UTC 905a2dd54edacbddf31e633193920b0ba8f8aff4
1 file changed +6
collectors/apps.plugin/apps_plugin.c
+6
@@ -4173,6 +4173,12 @@ int main(int argc, char **argv) {
4173 usec_t dt = heartbeat_next(&hb, step);
4174 #endif
4175
4176 + struct pollfd pollfd = { .fd = fileno(stdout), .events = POLLERR };
4177 + if (unlikely(poll(&pollfd, 1, 0) < 0))
4178 + fatal("Cannot check if a pipe is available");
4179 + if (unlikely(pollfd.revents & POLLERR))
4180 + fatal("Cannot write to a pipe");
4181 +
4182 if(!collect_data_for_all_processes()) {
4183 error("Cannot collect /proc data for running processes. Disabling apps.plugin...");
4184 printf("DISABLE\n");