summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp
index bd954c8..f95d9cc 100644
--- a/noncore/settings/sysinfo/processinfo.cpp
+++ b/noncore/settings/sysinfo/processinfo.cpp
@@ -1,119 +1,119 @@
1/********************************************************************** 1/**********************************************************************
2** ProcessInfo 2** ProcessInfo
3** 3**
4** Display process information 4** Display process information
5** 5**
6** Copyright (C) 2002, Dan Williams 6** Copyright (C) 2002, Dan Williams
7** williamsdr@acm.org 7** williamsdr@acm.org
8** http://draknor.net 8** http://draknor.net
9** 9**
10** This file may be distributed and/or modified under the terms of the 10** This file may be distributed and/or modified under the terms of the
11** GNU General Public License version 2 as published by the Free Software 11** GNU General Public License version 2 as published by the Free Software
12** Foundation and appearing in the file LICENSE.GPL included in the 12** Foundation and appearing in the file LICENSE.GPL included in the
13** packaging of this file. 13** packaging of this file.
14** 14**
15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE 15** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. 16** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
17** 17**
18**********************************************************************/ 18**********************************************************************/
19 19
20#include <qheader.h> 20#include <qheader.h>
21#include <qlistview.h> 21#include <qlistview.h>
22#include <qlayout.h> 22#include <qlayout.h>
23#include <qtimer.h> 23#include <qtimer.h>
24#include <qfile.h> 24#include <qfile.h>
25#include <qdir.h> 25#include <qdir.h>
26 26
27#include "processinfo.h" 27#include "processinfo.h"
28 28
29ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) 29ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
30 : QWidget( parent, name, fl ) 30 : QWidget( parent, name, fl )
31{ 31{
32 QVBoxLayout *vb = new QVBoxLayout( this, 5 ); 32 QVBoxLayout *vb = new QVBoxLayout( this, 5 );
33 33
34 ProcessView = new QListView( this, "ProcessView" ); 34 ProcessView = new QListView( this, "ProcessView" );
35 int colnum = ProcessView->addColumn( tr( "PID" ) ); 35 int colnum = ProcessView->addColumn( tr( "PID" ) );
36 ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); 36 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
37 colnum = ProcessView->addColumn( tr( "Command" ),90 ); 37 colnum = ProcessView->addColumn( tr( "Command" ),96 );
38 ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); 38 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
39 colnum = ProcessView->addColumn( tr( "Status" ) ); 39 colnum = ProcessView->addColumn( tr( "Status" ) );
40 ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); 40 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
41 colnum = ProcessView->addColumn( tr( "Time" ) ); 41 colnum = ProcessView->addColumn( tr( "Time" ) );
42 ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); 42 ProcessView->setColumnAlignment( colnum, Qt::AlignRight );
43 ProcessView->setAllColumnsShowFocus( TRUE ); 43 ProcessView->setAllColumnsShowFocus( TRUE );
44 connect( ProcessView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( viewProcess(QListViewItem *) ) ); 44 connect( ProcessView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( viewProcess(QListViewItem *) ) );
45 45
46 vb->addWidget( ProcessView ); 46 vb->addWidget( ProcessView );
47 47
48 QTimer *t = new QTimer( this ); 48 QTimer *t = new QTimer( this );
49 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); 49 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
50 t->start( 5000 ); 50 t->start( 5000 );
51 51
52 updateData(); 52 updateData();
53} 53}
54 54
55ProcessInfo::~ProcessInfo() 55ProcessInfo::~ProcessInfo()
56{ 56{
57} 57}
58 58
59void ProcessInfo::updateData() 59void ProcessInfo::updateData()
60{ 60{
61 QString processnum(""); 61 QString processnum("");
62 QString processcmd(""); 62 QString processcmd("");
63 QString processstatus(""); 63 QString processstatus("");
64 QString processtime(""); 64 QString processtime("");
65 int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, 65 int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime,
66 signal, blocked, sigignore, sigcatch; 66 signal, blocked, sigignore, sigcatch;
67 uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, 67 uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode,
68 endcode, startstack, kstkesp, kstkeip, wchan; 68 endcode, startstack, kstkesp, kstkeip, wchan;
69 char state; 69 char state;
70 char comm[255]; 70 char comm[255];
71 71
72 ProcessView->clear(); 72 ProcessView->clear();
73 73
74 QDir *procdir = new QDir("/proc"); 74 QDir *procdir = new QDir("/proc");
75 procdir->setFilter(QDir::Dirs); 75 procdir->setFilter(QDir::Dirs);
76 procdir->setSorting(QDir::Name); 76 procdir->setSorting(QDir::Name);
77 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); 77 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList()));
78 if ( proclist ) 78 if ( proclist )
79 { 79 {
80 QFileInfoListIterator it(*proclist); 80 QFileInfoListIterator it(*proclist);
81 QFileInfo *f; 81 QFileInfo *f;
82 while ( ( f = it.current() ) != 0 ) 82 while ( ( f = it.current() ) != 0 )
83 { 83 {
84 ++it; 84 ++it;
85 processnum = f->fileName(); 85 processnum = f->fileName();
86 if ( processnum >= "0" && processnum <= "99999" ) 86 if ( processnum >= "0" && processnum <= "99999" )
87 { 87 {
88 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); 88 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r");
89 89
90 if ( procfile ) 90 if ( procfile )
91 { 91 {
92 fscanf( procfile, 92 fscanf( procfile,
93 "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u", 93 "%d %s %c %d %d %d %d %d %u %u %u %u %u %d %d %d %d %d %d %u %u %d %u %u %u %u %u %u %u %u %d %d %d %d %u",
94 &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, 94 &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt,
95 &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, 95 &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout,
96 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, 96 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack,
97 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); 97 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan );
98 processnum = processnum.rightJustify( 5, ' ' ); 98 processnum = processnum.rightJustify( 5, ' ' );
99 processcmd = QString( comm ).replace( QRegExp( "(" ), "" ); 99 processcmd = QString( comm ).replace( QRegExp( "(" ), "" );
100 processcmd = processcmd.replace( QRegExp( ")" ), "" ); 100 processcmd = processcmd.replace( QRegExp( ")" ), "" );
101 processstatus = state; 101 processstatus = state;
102 processtime.setNum( ( utime + stime ) / 100 ); 102 processtime.setNum( ( utime + stime ) / 100 );
103 processtime = processtime.rightJustify( 9, ' ' ); 103 processtime = processtime.rightJustify( 9, ' ' );
104 fclose( procfile ); 104 fclose( procfile );
105 105
106 ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); 106 ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime );
107 } 107 }
108 } 108 }
109 } 109 }
110 } 110 }
111 111
112 delete proclist; 112 delete proclist;
113 delete procdir; 113 delete procdir;
114} 114}
115 115
116void ProcessInfo::viewProcess(QListViewItem *process) 116void ProcessInfo::viewProcess(QListViewItem *process)
117{ 117{
118//printf("Double click for PID: %s\n", process->text(0).stripWhiteSpace().latin1()); 118//printf("Double click for PID: %s\n", process->text(0).stripWhiteSpace().latin1());
119} 119}