read /proc files carefully

This commit is contained in:
Matthias Clasen 2008-11-10 01:53:20 +00:00
parent 10ccf27153
commit 75244b40c3
2 changed files with 28 additions and 1 deletions

View File

@ -7,7 +7,7 @@
Name: libgtop2
Summary: libgtop library (version 2)
Version: 2.24.0
Release: 1%{?dist}
Release: 2%{?dist}
License: GPLv2+
URL: http://download.gnome.org/sources/libgtop/2.24
Group: System Environment/Libraries
@ -21,6 +21,9 @@ BuildRequires: autoconf
BuildRequires: automake
BuildRequires: gtk-doc
# http://bugzilla.gnome.org/show_bug.cgi?id=468495
Patch0: read-cpuinfo-completely.patch
%description
libgtop is a library for portably obtaining information about processes,
such as their PID, memory usage, etc.
@ -39,6 +42,7 @@ files to allow you to develop with libgtop.
%prep
%setup -q -n libgtop-%{version}
%patch0 -p0 -b .read-cpuinfo-completely
%build
%configure --disable-gtk-doc --disable-static
@ -75,6 +79,9 @@ rm -rf $RPM_BUILD_ROOT
%exclude %{_datadir}/info
%changelog
* Sun Nov 9 2008 Matthias Clasen <mclasen@redhat.com> - 2.24.0-2
- Read /proc/cpuinfo completely (#467455)
* Tue Sep 23 2008 Matthias Clasen <mclasen@redhat.com> - 2.24.0-1
- Update to 2.24.0

View File

@ -0,0 +1,20 @@
Index: sysdeps/linux/sysinfo.c
===================================================================
--- sysdeps/linux/sysinfo.c (revision 2781)
+++ sysdeps/linux/sysinfo.c (working copy)
@@ -36,12 +36,12 @@
static void
init_sysinfo (glibtop *server)
{
- char buffer [16384];
+ gchar *buffer;
gchar ** processors;
if(G_LIKELY(sysinfo.flags)) return;
- file_to_buffer(server, buffer, sizeof buffer, FILENAME);
+ if (!g_file_get_contents("/proc/cpuinfo", &buffer, NULL, NULL)) return;
/* cpuinfo records are seperated by a blank line */
processors = g_strsplit(buffer, "\n\n", 0);