summaryrefslogtreecommitdiff
authordrw <drw>2003-02-01 02:15:18 (UTC)
committer drw <drw>2003-02-01 02:15:18 (UTC)
commit953cb6d9cb9da2829db8364bcfb4ff8af0b0ae26 (patch) (unidiff)
tree12bf039826f1d2106d446677f1bedd28d77e227b
parent766f09a89eef17808e77836f76371aab8ebc4c1c (diff)
downloadopie-953cb6d9cb9da2829db8364bcfb4ff8af0b0ae26.zip
opie-953cb6d9cb9da2829db8364bcfb4ff8af0b0ae26.tar.gz
opie-953cb6d9cb9da2829db8364bcfb4ff8af0b0ae26.tar.bz2
Fix display problem after killing a process
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/settings/sysinfo/processinfo.cpp5
1 files changed, 1 insertions, 4 deletions
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp
index 9a5446a..769410f 100644
--- a/noncore/settings/sysinfo/processinfo.cpp
+++ b/noncore/settings/sysinfo/processinfo.cpp
@@ -68,123 +68,120 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl )
68 SignalCB->insertItem( "18: SIGCONT" ); 68 SignalCB->insertItem( "18: SIGCONT" );
69 SignalCB->insertItem( "19: SIGSTOP" ); 69 SignalCB->insertItem( "19: SIGSTOP" );
70 layout->addWidget( SignalCB, 1, 0 ); 70 layout->addWidget( SignalCB, 1, 0 );
71 QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) ); 71 QWhatsThis::add( SignalCB, tr( "Select a signal here and then click the Send button to the right to send to this process." ) );
72 72
73 SendButton = new QPushButton( this, "SendButton" ); 73 SendButton = new QPushButton( this, "SendButton" );
74 SendButton->setMinimumSize( QSize( 50, 24 ) ); 74 SendButton->setMinimumSize( QSize( 50, 24 ) );
75 SendButton->setMaximumSize( QSize( 50, 24 ) ); 75 SendButton->setMaximumSize( QSize( 50, 24 ) );
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 ProcessView->clear(); 104 ProcessView->clear();
105 105
106 QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs); 106 QDir *procdir = new QDir("/proc", 0, QDir::Name, QDir::Dirs);
107 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList())); 107 QFileInfoList *proclist = new QFileInfoList(*(procdir->entryInfoList()));
108 if ( proclist ) 108 if ( proclist )
109 { 109 {
110 QFileInfoListIterator it(*proclist); 110 QFileInfoListIterator it(*proclist);
111 QFileInfo *f; 111 QFileInfo *f;
112 while ( ( f = it.current() ) != 0 ) 112 while ( ( f = it.current() ) != 0 )
113 { 113 {
114 ++it; 114 ++it;
115 QString processnum = f->fileName(); 115 QString processnum = f->fileName();
116 if ( processnum >= "1" && processnum <= "99999" ) 116 if ( processnum >= "1" && processnum <= "99999" )
117 { 117 {
118 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); 118 FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r");
119 119
120 if ( procfile ) 120 if ( procfile )
121 { 121 {
122 fscanf( procfile, 122 fscanf( procfile,
123 "%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", 123 "%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",
124 &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, 124 &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt,
125 &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, 125 &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout,
126 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, 126 &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack,
127 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); 127 &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan );
128 processnum = processnum.rightJustify( 5, ' ' ); 128 processnum = processnum.rightJustify( 5, ' ' );
129 QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); 129 QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" );
130 QString processstatus = QChar(state); 130 QString processstatus = QChar(state);
131 QString processtime = QString::number( ( utime + stime ) / 100 ); 131 QString processtime = QString::number( ( utime + stime ) / 100 );
132 processtime = processtime.rightJustify( 9, ' ' ); 132 processtime = processtime.rightJustify( 9, ' ' );
133 fclose( procfile ); 133 fclose( procfile );
134 134
135 ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); 135 ( void ) new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime );
136 } 136 }
137 } 137 }
138 } 138 }
139 } 139 }
140 140
141 delete proclist; 141 delete proclist;
142 delete procdir; 142 delete procdir;
143} 143}
144 144
145void ProcessInfo::slotSendClicked() 145void ProcessInfo::slotSendClicked()
146{ 146{
147 QListViewItem *currprocess = ProcessView->currentItem(); 147 QListViewItem *currprocess = ProcessView->currentItem();
148 if ( !currprocess ) 148 if ( !currprocess )
149 { 149 {
150 return; 150 return;
151 } 151 }
152 152
153 QString capstr = tr( "You really want to send\n" ); 153 QString capstr = tr( "You really want to send\n" );
154 capstr.append( SignalCB->currentText() ); 154 capstr.append( SignalCB->currentText() );
155 capstr.append( "\nto this process?" ); 155 capstr.append( "\nto this process?" );
156 156
157 157
158 if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, 158 if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr,
159 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) 159 QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes )
160 { 160 {
161 QString sigstr = SignalCB->currentText(); 161 QString sigstr = SignalCB->currentText();
162 sigstr.truncate(2); 162 sigstr.truncate(2);
163 int sigid = sigstr.toUInt(); 163 int sigid = sigstr.toUInt();
164 if ( kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ) == 0 ) 164 kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid );
165 {
166 hide();
167 }
168 } 165 }
169 166
170} 167}
171 168
172void ProcessInfo::viewProcess( QListViewItem *process ) 169void ProcessInfo::viewProcess( QListViewItem *process )
173{ 170{
174 QString pid= process->text( 0 ).stripWhiteSpace(); 171 QString pid= process->text( 0 ).stripWhiteSpace();
175 QString command = process->text( 1 ); 172 QString command = process->text( 1 );
176 ProcessDtl->setCaption( pid + " - " + command ); 173 ProcessDtl->setCaption( pid + " - " + command );
177 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); 174 FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r");
178 if ( statfile ) 175 if ( statfile )
179 { 176 {
180 char line[81]; 177 char line[81];
181 fgets( line, 81, statfile ); 178 fgets( line, 81, statfile );
182 ProcessDtl->detailView->setText( line ); 179 ProcessDtl->detailView->setText( line );
183 while ( fgets( line, 81, statfile ) ) 180 while ( fgets( line, 81, statfile ) )
184 { 181 {
185 ProcessDtl->detailView->append( line ); 182 ProcessDtl->detailView->append( line );
186 } 183 }
187 fclose( statfile ); 184 fclose( statfile );
188 } 185 }
189 ProcessDtl->showMaximized(); 186 ProcessDtl->showMaximized();
190} 187}