Compare commits

...

2 Commits

Author SHA1 Message Date
Benoît Dejean
e1d6e713fc Released 2.22.2
svn path=/branches/gnome-2-22/; revision=2745
2008-05-23 21:54:03 +00:00
Benoît Dejean
1634698050 Fixed parsing of big /proc/stat for uptime.
Closes #529946.

svn path=/branches/gnome-2-22/; revision=2742
2008-04-29 17:57:01 +00:00
3 changed files with 24 additions and 12 deletions

5
NEWS
View File

@@ -1,3 +1,8 @@
24 May 2008: Overview of changes in 2.22.2
==========================================
* linux:
- fixed parsing of huge /proc/stat.
04 April 2008: Overview of changes in 2.22.1 04 April 2008: Overview of changes in 2.22.1
============================================ ============================================
* Fixed compilation/dist for !linux. * Fixed compilation/dist for !linux.

View File

@@ -4,7 +4,7 @@ dnl
m4_define([libgtop_major_version], [2]) m4_define([libgtop_major_version], [2])
m4_define([libgtop_minor_version], [22]) m4_define([libgtop_minor_version], [22])
m4_define([libgtop_micro_version], [1]) m4_define([libgtop_micro_version], [2])
m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version]) m4_define([libgtop_version], [libgtop_major_version.libgtop_minor_version.libgtop_micro_version])
dnl increment if the interface has additions, changes, removals. dnl increment if the interface has additions, changes, removals.

View File

@@ -119,20 +119,27 @@ file_to_buffer(glibtop *server, char *buffer, size_t bufsiz, const char *filenam
static unsigned long static unsigned long
read_boot_time(glibtop *server) read_boot_time(glibtop *server)
{ {
char buffer[BUFSIZ]; char* line = NULL;
char *btime; size_t size = 0;
FILE* stat;
unsigned long btime = 0;
file_to_buffer(server, buffer, sizeof buffer, "/proc/stat"); if (!(stat = fopen("/proc/stat", "r"))) {
glibtop_error_io_r(server, "fopen(\"/proc/stat\")");
btime = strstr(buffer, "btime"); goto out;
if (!btime) {
glibtop_warn_io_r(server, "cannot find btime in /proc/stat");
return 0UL;
} }
btime = skip_token(btime); while (getline(&line, &size, stat) != -1) {
return strtoul(btime, NULL, 10); if (!strncmp(line, "btime", 5)) {
btime = strtoul(skip_token(line), NULL, 10);
break;
}
}
free(line);
fclose(stat);
out:
return btime;
} }