diff options
author | Martin Baulig <baulig@suse.de> | 2001-02-13 12:31:57 +0000 |
---|---|---|
committer | Martin Baulig <martin@src.gnome.org> | 2001-02-13 12:31:57 +0000 |
commit | 38e55efd2da0c499ccd186edea99b3128c2ec20f (patch) | |
tree | 5aa58d97f8533fbacf860489054ced50dfb05ec7 | |
parent | 67c9c8e3e30a5c74c67cf43c699f1deab0fe925c (diff) | |
download | libgtop-38e55efd2da0c499ccd186edea99b3128c2ec20f.tar.gz |
Fix bug #14076.
2001-02-13 Martin Baulig <baulig@suse.de>
Fix bug #14076.
* open.c (glibtop_open_s): Check whether /proc/1/cpu exists to
detect SMP support rather than reading /proc/stat; on Linux 2.4.x,
/proc/stat has "cpu" and "cpu0" entries even for non-SMP systems.
-rw-r--r-- | sysdeps/linux/ChangeLog | 8 | ||||
-rw-r--r-- | sysdeps/linux/open.c | 8 |
2 files changed, 16 insertions, 0 deletions
diff --git a/sysdeps/linux/ChangeLog b/sysdeps/linux/ChangeLog index 95bb2640..f24e64d9 100644 --- a/sysdeps/linux/ChangeLog +++ b/sysdeps/linux/ChangeLog @@ -1,3 +1,11 @@ +2001-02-13 Martin Baulig <baulig@suse.de> + + Fix bug #14076. + + * open.c (glibtop_open_s): Check whether /proc/1/cpu exists to + detect SMP support rather than reading /proc/stat; on Linux 2.4.x, + /proc/stat has "cpu" and "cpu0" entries even for non-SMP systems. + 2000-01-22 Martin Baulig <martin@home-of-linux.org> * procargs.c (glibtop_get_proc_args_s): Set correct `buf->size' and diff --git a/sysdeps/linux/open.c b/sysdeps/linux/open.c index f54a7e8d..08bfa379 100644 --- a/sysdeps/linux/open.c +++ b/sysdeps/linux/open.c @@ -62,6 +62,7 @@ glibtop_open_s (glibtop *server, const char *program_name, const unsigned flags) { char buffer [BUFSIZ], *p; + struct stat statb; int fd, len, i; server->name = program_name; @@ -71,6 +72,13 @@ glibtop_open_s (glibtop *server, const char *program_name, server->ncpu = 0; + /* On Linux 2.4.x, /proc/stat has "cpu" and "cpu0" entries even + * for non-SMP systems. Checking whether /proc/<pid>/cpu exists + * is a much better way to detect SMP. */ + + if (stat ("/proc/1/cpu", &statb)) + return; + fd = open (FILENAME, O_RDONLY); if (fd < 0) glibtop_error_io_r (server, "open (%s)", FILENAME); |