Compare commits
2 Commits
2.36.0
...
LIBGTOP_2_
Author | SHA1 | Date | |
---|---|---|---|
|
e1d6e713fc | ||
|
1634698050 |
5
NEWS
5
NEWS
@@ -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.
|
||||||
|
@@ -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.
|
||||||
|
@@ -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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user