kpv)
This application is created as an assigment in the course Linux System Programming, fall 2000, taught by Risto Lahdelma. It is one of the big projects that require no examination or exercises to be made. The deadline for this assignment was 2000-01-31.
This is the original specifikation of the assignment, as found on the page http://monster.cs.utu.fi/linuxcourse2000/projects.htm:
Graphical user interface for viewing processes (1-2) Make a graphical version of the top-program to display a list of processes and their states. The process list is updated using a refresh command. Implement also commands for sending signals to processes and changing their priority (nice).
The application is written in C++ on a RedHat Linux system running the kernel 2.4.0-test10. The code should be compilable on older systems too. The code is totally about 2500 lines, of which a significant part (of course) if comments. A total of 15 source files are used, with an some additional administrative files.
Although kpv is called KDE Process Viewer it does not require KDE at all. It only needs Qt 2.0 or higher. The system used for developing has version 2.2.1. Other requirements include a fairly recent glibc which needs to have GNU regular expressions, which are used for parsing data. Other requirements are those of Qt.
To rebuild the documentation you are reading now the program doxygen is needed. The used version was 1.2.3, but older versions will most likely work equally well.
kpv can be downloaded here. It is currently only available as a tar.gz, but I may package it as a RPM or DEB if I find the time and interest.
Unpack the file with:
% tar zxf kpv-1.0.tar.gz
which will create a new directory kpv-1.0.
To compile kpv you should only need to use the following commands:
% cd kpv-1.0 % ./configure % make all install
You may however need to add a few options to configure so that it recognizes and finds Qt. These are:
--with-qt2-includes=path which gives the directory where the Qt header files are located. If they can be found in the normal headerfile search path this option is not needed.
--with-qt2-libs=path which gives the directory where the shared Qt library libqt can be found. If it can be found in the normal library search path this option is not needed.
--with-qt2-moc=program which gives the full path to the moc program. This option is needed if a binary moc in the normal path is not the correct version.
For other options that can be given to configure see the list of options that you get with:
% ./configure --help
Of these options only the following three options are really used:
--prefix=path which gives the overall prefix (defaults to /usr/local/).
--bindir=path which gives the installation path for the main application (defaults to $prefix/bin).
--mandir=path which gives the path for the manual page. The suffix man1 is added to the durectory, which defaults to $prefix/man.
Installation requires root privilegies if installed in the default location, but using the option --prefix=path the application can be installed anywhere. The other documentation in the source package is not installed anywhere on the system.
To start the application simply type:
% kpv
or if it is not in the normal search path use the full path to the binary. This will launch the application and display its window. kpv uses no own commandline options, and only those recognized by Qt will be used at all.
The main window looks like:
The contents of the window are self explanatory and need no further descriptions. For more information see the manual page on top(1) or ps(1).
As the original specification said to have manual refresh the user must manually refresh the display. This is done by pressing the right mousebutton in the widget that lists the processes, thus showing a popup menu. The menu has an entry Refresh that rereads the list of processes, the amount of used memory, number of processes and load average.
To send a process a signal first highlight a process by clicking in the display on the desired process. Unless a process is selected the popup menu will not allow any signals to be sent. Bring up the popup menu, activate the submenu Send signal and choose the wanted signal. The signal is then sent to the process and the display is updated. Not all signals can be sent, only a few selected (relevant) signals are possible.
Note that normal access restrictions are effective when sending signals to processes of other users.
The priority for a process can be set in the same manner as when killing processes, with the difference being that the submenu is called Renice. This sets a new priority for the process, if the permissions of the current user allows it. Only root can set a higher priority (lower value) for a process; normal users can only lower priorities (higher value).
Note that normal access restrictions are effective when setting priorities of processes of other users.
This application is licensed under GPL (GNU General Public Licence). The license is also included in the source package as the file GPL.
All classes and files used in the application are documented using the tool doxygen. See the online documentation for each class and file for more information.
The main part of the application, and the only remotely difficult one too, is to gather the needed information that the application needs. All information that kpv displays is read from the /proc/ filesystem. Most data in this directory is pure text and reflects the state of various parts of the system. The main files used are:
/proc/loadvg which contains information about the system load average for the last 1, 5 and 15 minutes.
/proc/meminfo which contains information about available and used memory, both normal RAM and swap space.
Apart from these two files each process in the system will also have an own directory. The directory is always
To make the parsing easier regular expressions are used to identify the names of the directories for the processes. Other data, such as the actual files, always follows a tightly specified format and for reading those normal C++ streams are used.
Jan Ekholm is a student at the Department of Computer Science at Åbo Akademi, with student number 20509.
/proc/process_id/, where process_id is the normal Unix process id. Each directory contains information about that specific process. From these directories the files stat and status are read to extract the necessary information.
Generated at Wed Jan 31 18:32:46 2001 for kpv by
1.2.3 written by Dimitri van Heesch,
© 1997-2000