MemAvailable is in /proc/meminfo since Linux 3.14.
This aligns the reported memory usage with the memory usage
reported by xfce4-systemload-plugin.
Closes!10
The patch that was already committed apparently fixes the issue but
using a non-documented method. This patch fixes the issue as described in
"man proc". (The UID is extracted by parsing /proc/*/status not by using
stat() on /proc/*/task). Also, this patch can easily be extended to also
report other UIDs besides the "effective" UID: real, effective, saved
set, and filesystem UIDs.
Something strange happened when doing a comparison between a guint type
and sizeof(), turning it back to gint fixes the issue. Fix other
compiler warnings at the same time.
The fix is very trivial, all it takes is initializing values passed to
scanf to zero. In fact format conversions inside scanf/printf may fail
otherwise.
The CPU usage computation done for the processes were broken when the
refresh rate was different than a second. The introduced fix is only
necessary for the Linux and OpenSolaris implementations.
The functions send_signal_to_pid() and set_priority_to_pid() are using
POSIX functions and “should” be safe in task-manager.c. Still keep the
enumeration as a bridge between virtual values and real values, there is
no benefit removing them (wasting minutes) and it won't make the code
look better (or worse).
The functions have been removed from the Linux and BSD implementations.
The function pid_is_sleeping() is implement by the different OS
implementations and returns TRUE or FALSE. It is used in the tree view
context menu to show either the signal Stop or Continue.
Base signals and priorities are defined inside the task-manager.h file
to be reused as general values inside the interface. The different OS
implementations have to do the conversion from the enumeration to real
values.
Fix one segfault where some processes like “ls” live very briefly and
those may be catched up but at the time to read the cmdline the process
tree already disappeared. Also terminate the cmdline with \0.
I ran the application on my netbook, which doesn't have /proc/<PID>/comm
files... The code has been updated to read the short command from the
buffer.
The code still uses scanf to parse the stat file, but the process name
is being cleansed so that it never fails. The name is read from the
“comm” file. It is still a truncated version of the name, and will
likely remain for very long like this. There is one solution, but since
the name isn't currently used inside the interface there is no point
wasting time.
On the Linux implementation, when a process name has a space in it the
sscanf function is unable to parse the line properly. This will have to
be changed, but in the meantime ignore such processes and avoid the
segfault, there are going to be Beta releases.
Added a utility function that stores old jiffles inside a hash table in
order to be able to provide usage values of system and user time in
percentage.
This commit is the second of an incremental serie. There will be other
commits with the information about tasks and the support for BSD and
Solaris once things are settled.
The TaskManager class is build with a new source task-manager-linux.c
that provides functions specific to the Linux implementation. It has
functions to read the usage of the memory/swap and the CPU.