No longer use `glibtop_machine.h' for Linux.
1998-07-03 Martin baulig <martin@home-of-linux.org> * macros/gnome-libgtop-sysdeps.m4: No longer use `glibtop_machine.h' for Linux. * sysdeps/linux/glibtop_machine.h: Removed. * sysdeps/guile/guile.awk: Using `scm_append' instead of `gh_append'. * sysdeps/guile/names/guile-names.awk: dito. * sysdeps/linux/*.c: Using code from stable branch again. * include/glibtop/parameter.h: New file. * lib/parameter.c: New file. * lib/{open, init}.c: Done some more work on server initialization
This commit is contained in:
committed by
Martin Baulig
parent
94715ef718
commit
9532dadc2e
@@ -35,8 +35,7 @@ static const unsigned long _glibtop_sysdeps_cpu =
|
||||
void
|
||||
glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
|
||||
{
|
||||
char buffer [BUFSIZ], *tmp;
|
||||
int fd = 0, ret;
|
||||
FILE *f;
|
||||
|
||||
glibtop_init_r (&server, 0, 0);
|
||||
|
||||
@@ -44,25 +43,15 @@ glibtop_get_cpu_s (glibtop *server, glibtop_cpu *buf)
|
||||
|
||||
buf->flags = _glibtop_sysdeps_cpu;
|
||||
|
||||
fd = open (FILENAME, O_RDONLY);
|
||||
if (fd == -1)
|
||||
glibtop_error_r (server, "open (%s): %s",
|
||||
FILENAME, strerror (errno));
|
||||
f = fopen ("/proc/stat", "r");
|
||||
if (!f) return;
|
||||
|
||||
ret = read (fd, buffer, BUFSIZ);
|
||||
if (ret == -1)
|
||||
glibtop_error_r (server, "read (%s): %s",
|
||||
FILENAME, strerror (errno));
|
||||
|
||||
tmp = skip_token (buffer); /* "cpu" */
|
||||
|
||||
buf->user = strtoul (tmp, &tmp, 10);
|
||||
buf->nice = strtoul (tmp, &tmp, 10);
|
||||
buf->sys = strtoul (tmp, &tmp, 10);
|
||||
buf->idle = strtoul (tmp, &tmp, 10);
|
||||
fscanf (f, "cpu %lu %lu %lu %lu\n",
|
||||
&buf->user, &buf->nice, &buf->sys, &buf->idle);
|
||||
|
||||
buf->total = buf->user + buf->nice + buf->sys + buf->idle;
|
||||
|
||||
buf->frequency = 100;
|
||||
close (fd);
|
||||
|
||||
fclose (f);
|
||||
}
|
||||
|
Reference in New Issue
Block a user