diff --git a/src/libs/zbxicmpping/icmpping.c b/src/libs/zbxicmpping/icmpping.c index e9655f9..4954e34 100644 --- a/src/libs/zbxicmpping/icmpping.c +++ b/src/libs/zbxicmpping/icmpping.c @@ -51,6 +51,23 @@ static int fping_ipv6_supported; #define FPING_CHECK_EXPIRED 3600 /* seconds, expire detected fping options every hour */ static time_t fping_check_reset_at; /* time of the last fping options expiration */ +static char *zbx_fgets(char *buffer, int size, FILE *fp) +{ + char *ret; + + for (;;) { + errno = 0; + if (NULL == (ret = fgets(buffer, size, fp))) { + if (NULL == ret && EINTR == errno) + continue; + } + + break; + } + + return ret; +} + static void get_source_ip_option(const char *fping, const char **option, unsigned char *checked) { FILE *f; @@ -543,7 +560,7 @@ static int process_ping(ZBX_FPING_HOST *hosts, int hosts_count, int count, int i goto out; } - if (NULL == fgets(tmp, (int)tmp_size, f)) + if (NULL == zbx_fgets(tmp, (int)tmp_size, f)) { zbx_snprintf(tmp, tmp_size, "no output"); } @@ -666,7 +683,7 @@ static int process_ping(ZBX_FPING_HOST *hosts, int hosts_count, int count, int i #endif ret = SUCCEED; } - while (NULL != fgets(tmp, (int)tmp_size, f)); + while (NULL != zbx_fgets(tmp, (int)tmp_size, f)); for (i = 0; i < hosts_count; i++) zbx_free(hosts[i].status);