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 + + 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 * 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//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);