summaryrefslogtreecommitdiff
authordrw <drw>2003-03-19 23:37:49 (UTC)
committer drw <drw>2003-03-19 23:37:49 (UTC)
commitdbb584139c579e55cf340eaed5eb873ecb69baf5 (patch) (unidiff)
tree9f616be06919da82a49bce071c83537ffd4ba82f
parenta83c7aed577b15e23a8baf7c21af61f4b40ffbb0 (diff)
downloadopie-dbb584139c579e55cf340eaed5eb873ecb69baf5.zip
opie-dbb584139c579e55cf340eaed5eb873ecb69baf5.tar.gz
opie-dbb584139c579e55cf340eaed5eb873ecb69baf5.tar.bz2
Fix for bug #733
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp16
1 files changed, 10 insertions, 6 deletions
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp
index 2232771..1de1a19 100644
--- a/noncore/settings/sysinfo/processinfo.cpp
+++ b/noncore/settings/sysinfo/processinfo.cpp
@@ -76,126 +76,130 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
76 SendButton->setText( tr( "Send" ) ); 76 SendButton->setText( tr( "Send" ) );
77 connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); 77 connect( SendButton, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) );
78 layout->addWidget( SendButton, 1, 1 ); 78 layout->addWidget( SendButton, 1, 1 );
79 QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) ); 79 QWhatsThis::add( SendButton, tr( "Click here to send the selected signal to this process." ) );
80 80
81 QTimer *t = new QTimer( this ); 81 QTimer *t = new QTimer( this );
82 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); 82 connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) );
83 t->start( 5000 ); 83 t->start( 5000 );
84 84
85 updateData(); 85 updateData();
86 86
87 ProcessDtl = new Detail(); 87 ProcessDtl = new Detail();
88 QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) ); 88 QWhatsThis::add( ProcessDtl->detailView, tr( "This area shows detailed information about this process." ) );
89} 89}
90 90
91ProcessInfo::~ProcessInfo() 91ProcessInfo::~ProcessInfo()
92{ 92{
93} 93}
94 94
95void ProcessInfo::updateData() 95void ProcessInfo::updateData()
96{ 96{
97 int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime, 97 int pid, ppid, pgrp, session, tty, tpgid, utime, stime, cutime, cstime, counter, priority, starttime,
98 signal, blocked, sigignore, sigcatch; 98 signal, blocked, sigignore, sigcatch;
99 uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode, 99 uint flags, minflt, cminflt, majflt, cmajflt, timeout, itrealvalue, vsize, rss, rlim, startcode,
100 endcode, startstack, kstkesp, kstkeip, wchan; 100 endcode, startstack, kstkesp, kstkeip, wchan;
101 char state; 101 char state;
102 char comm[64]; 102 char comm[64];
103 103
104 QString selectedpid; 104 QString selectedpid;
105 QListViewItem *curritem = ProcessView->currentItem(); 105 QListViewItem *curritem = ProcessView->currentItem();
106 if ( curritem ) 106 if ( curritem )
107 { 107 {
108 selectedpid = curritem->text( 0 ); 108 selectedpid = curritem->text( 0 );
109 } 109 }
110 110
111 ProcessView->clear(); 111 ProcessView->clear();
112 112
113 QListViewItem *newitem; 113 QListViewItem *newitem;
114 QListViewItem *selecteditem = 0x0; 114 QListViewItem *selecteditem = 0x0;
115 QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); 115 QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs);
116 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); 116 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList()));
117 if ( proclist ) 117 if ( proclist )
118 { 118 {
119 QFileInfoListIterator it(*proclist); 119 QFileInfoListIterator it(*proclist);
120 QFileInfo *f; 120 QFileInfo *f;
121 while ( ( f = it.current() ) != 0 ) 121 while ( ( f = it.current() ) != 0 )
122 { 122 {
123 ++it; 123 ++it;
124 QString processnum = f->fileName(); 124 QString processnum = f->fileName();
125 if ( processnum >= "1" && processnum <= "99999" ) 125 if ( processnum >= "1" && processnum <= "99999" )
126 { 126 {
127 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); 127 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r");
128 128
129 if ( procfile ) 129 if ( procfile )
130 { 130 {
131 fscanf( procfile, 131 fscanf( procfile,
132 "%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", 132 "%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",
133 &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, 133 &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt,
134 &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, 134 &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout,
135 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, 135 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack,
136 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); 136 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan );
137 processnum = processnum.rightJustify( 5, ' ' ); 137 processnum = processnum.rightJustify( 5, ' ' );
138 QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); 138 QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" );
139 QString processstatus = QChar(state); 139 QString processstatus = QChar(state);
140 QString processtime = QString::number( ( utime + stime ) / 100 ); 140 QString processtime = QString::number( ( utime + stime ) / 100 );
141 processtime = processtime.rightJustify( 9, ' ' ); 141 processtime = processtime.rightJustify( 9, ' ' );
142 fclose( procfile ); 142 fclose( procfile );
143 143
144 newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); 144 newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime );
145 if ( processnum == selectedpid ) 145 if ( processnum == selectedpid )
146 { 146 {
147 selecteditem = newitem; 147 selecteditem = newitem;
148 } 148 }
149 } 149 }
150 } 150 }
151 } 151 }
152 ProcessView->setCurrentItem( selecteditem ); 152 ProcessView->setCurrentItem( selecteditem );
153 } 153 }
154 154
155 delete proclist; 155 delete proclist;
156 delete procdir; 156 delete procdir;
157} 157}
158 158
159void ProcessInfo::slotSendClicked() 159void ProcessInfo::slotSendClicked()
160{ 160{
161 QListViewItem *currprocess = ProcessView->currentItem(); 161 QListViewItem *currprocess = ProcessView->currentItem();
162 if ( !currprocess ) 162 if ( !currprocess )
163 { 163 {
164 return; 164 return;
165 } 165 }
166 166
167 QString capstr = tr( "You really want to send\n" ); 167 QString capstr = tr( "You really want to send\n" );
168 capstr.append( SignalCB->currentText() ); 168 capstr.append( SignalCB->currentText() );
169 capstr.append( "\nto this process?" ); 169 capstr.append( "\nto this process?" );
170 170
171 171
172 if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, 172 if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr,
173 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) 173 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
174 { 174 {
175 QString sigstr = SignalCB->currentText(); 175 currprocess = ProcessView->currentItem();
176 sigstr.truncate(2); 176 if ( currprocess )
177 int sigid = sigstr.toUInt(); 177 {
178 kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); 178 QString sigstr = SignalCB->currentText();
179 sigstr.truncate(2);
180 int sigid = sigstr.toUInt();
181 kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid );
182 }
179 } 183 }
180 184
181} 185}
182 186
183void ProcessInfo::viewProcess( QListViewItem *process ) 187void ProcessInfo::viewProcess( QListViewItem *process )
184{ 188{
185 QString pid= process->text( 0 ).stripWhiteSpace(); 189 QString pid= process->text( 0 ).stripWhiteSpace();
186 QString command = process->text( 1 ); 190 QString command = process->text( 1 );
187 ProcessDtl->setCaption( pid + " - " + command ); 191 ProcessDtl->setCaption( pid + " - " + command );
188 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); 192 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r");
189 if ( statfile ) 193 if ( statfile )
190 { 194 {
191 char line[81]; 195 char line[81];
192 fgets( line, 81, statfile ); 196 fgets( line, 81, statfile );
193 ProcessDtl->detailView->setText( line ); 197 ProcessDtl->detailView->setText( line );
194 while ( fgets( line, 81, statfile ) ) 198 while ( fgets( line, 81, statfile ) )
195 { 199 {
196 ProcessDtl->detailView->append( line ); 200 ProcessDtl->detailView->append( line );
197 } 201 }
198 fclose( statfile ); 202 fclose( statfile );
199 } 203 }
200 ProcessDtl->showMaximized(); 204 ProcessDtl->showMaximized();
201} 205}