diff options
author | Vladimir Kobal <vlad@prokk.net> | 2020-03-31 23:01:37 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-31 23:01:37 +0300 |
commit | 905a2dd54edacbddf31e633193920b0ba8f8aff4 (patch) | |
tree | d05ab5518a0203942bf14f2e7924f18998e1fa71 /collectors/apps.plugin | |
parent | b7bf0721fbbea9961476458381d6d04760013e1a (diff) |
Fix broken pipe ignoring in apps plugin (#8554)
* Fix broken pipe ignoring in apps plugin
* Use poll instead of write
Diffstat (limited to 'collectors/apps.plugin')
-rw-r--r-- | collectors/apps.plugin/apps_plugin.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/collectors/apps.plugin/apps_plugin.c b/collectors/apps.plugin/apps_plugin.c index 93159406e4..5f40270132 100644 --- a/collectors/apps.plugin/apps_plugin.c +++ b/collectors/apps.plugin/apps_plugin.c @@ -4173,6 +4173,12 @@ int main(int argc, char **argv) { usec_t dt = heartbeat_next(&hb, step); #endif + struct pollfd pollfd = { .fd = fileno(stdout), .events = POLLERR }; + if (unlikely(poll(&pollfd, 1, 0) < 0)) + fatal("Cannot check if a pipe is available"); + if (unlikely(pollfd.revents & POLLERR)) + fatal("Cannot write to a pipe"); + if(!collect_data_for_all_processes()) { error("Cannot collect /proc data for running processes. Disabling apps.plugin..."); printf("DISABLE\n"); |