diff --git a/src/linux.cc b/src/linux.cc index 4e6609d05c..1096d728d3 100644 --- a/src/linux.cc +++ b/src/linux.cc @@ -902,8 +902,12 @@ void determine_longstat_file(void) { #define MAX_PROCSTAT_LINELEN 255 FILE *stat_fp; static int reported = 0; + static bool first = true; char buf[MAX_PROCSTAT_LINELEN + 1]; + if (! first) return; + first = false; + if (!(stat_fp = open_file("/proc/stat", &reported))) return; while (!feof(stat_fp) && fgets(buf, MAX_PROCSTAT_LINELEN, stat_fp) != nullptr) { @@ -1000,6 +1004,7 @@ int update_stat(void) { } if (!stat_template) { + determine_longstat_file(); stat_template = KFLAG_ISSET(KFLAG_IS_LONGSTAT) ? TMPL_LONGSTAT : TMPL_SHORTSTAT; }