From 302fae854c6f9dff7f7654b21045b40772dca495 Mon Sep 17 00:00:00 2001 From: Philip Kovacs Date: Tue, 26 Dec 2006 20:49:35 +0000 Subject: [PATCH] clear conky vars on disconnect/failure to open files git-svn-id: https://conky.svn.sourceforge.net/svnroot/conky/trunk/conky1@820 7f574dfc-610e-0410-a909-a81674777703 --- ChangeLog | 3 +++ src/linux.c | 15 +++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/ChangeLog b/ChangeLog index fa534803..2a057c44 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ # $Id$ +2006-12-26 + * Clear conky vars on disconnect/failure to open files. + 2006-12-23 * Updated to libmpdclient 0.12.0 diff --git a/src/linux.c b/src/linux.c index 446e4e4a..228011b2 100644 --- a/src/linux.c +++ b/src/linux.c @@ -75,6 +75,7 @@ void update_uptime() if (!(fp = open_file("/proc/uptime", &rep))) { + info.uptime=0.0; return; } fscanf(fp, "%lf", &info.uptime); @@ -149,7 +150,10 @@ inline void update_net_stats() /* open file and ignore first two lines */ if (!(net_dev_fp = open_file("/proc/net/dev", &rep))) + { + clear_net_stats (); return; + } fgets(buf, 255, net_dev_fp); /* garbage */ fgets(buf, 255, net_dev_fp); /* garbage (field names) */ @@ -326,6 +330,7 @@ void update_total_processes() if (!(fp = open_file("/proc/loadavg", &rep))) { + info.procs=0; return; } fscanf(fp, "%*f %*f %*f %*d/%hd", &info.procs ); @@ -428,7 +433,14 @@ inline static void update_stat() } if (!(stat_fp = open_file("/proc/stat", &rep))) + { + info.run_procs=0; + if (info.cpu_usage) + { + memset(info.cpu_usage, 0, info.cpu_count * sizeof (float)); + } return; + } index = 0; while (!feof(stat_fp)) { @@ -1519,7 +1531,10 @@ void update_diskio() int col_count = 0; if (!(fp =open_file("/proc/diskstats", &rep))) + { + diskio_value=0; return; + } /* read reads and writes from all disks (minor = 0), including * cd-roms and floppies, and summ them up