Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

KDE Process Viewer (kpv)

Introduction

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.

Original specification

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).
   

Project information

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.

Installation

Requirements

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.

Downloading

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.

Unpacking

Unpack the file with:

   % tar zxf kpv-1.0.tar.gz
   

which will create a new directory kpv-1.0.

Compiling

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:

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:

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.

Usage

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:

kpv screenshot

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).

Refreshing the display

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.

Sending signals to processes

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.

Setting the priority

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.

License

This application is licensed under GPL (GNU General Public Licence). The license is also included in the source package as the file GPL.

Documentation

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.

Gathering 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:

Apart from these two files each process in the system will also have an own directory. The directory is always /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.

Regular expressions

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.

About the author

Jan Ekholm is a student at the Department of Computer Science at Åbo Akademi, with student number 20509.


Generated at Wed Jan 31 18:32:46 2001 for kpv by doxygen1.2.3 written by Dimitri van Heesch, © 1997-2000