-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 16 |
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 @@ -124,78 +124,82 @@ void ProcessInfo::updateData() QString processnum = f->fileName(); if ( processnum >= "1" && processnum <= "99999" ) { FILE *procfile = fopen( ( QString ) ( "/proc/" + processnum + "/stat"), "r"); if ( procfile ) { fscanf( procfile, "%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", &pid, comm, &state, &ppid, &pgrp, &session,&tty, &tpgid, &flags, &minflt, &cminflt, &majflt, &cmajflt, &utime, &stime, &cutime, &cstime, &counter, &priority, &timeout, &itrealvalue, &starttime, &vsize, &rss, &rlim, &startcode, &endcode, &startstack, &kstkesp, &kstkeip, &signal, &blocked, &sigignore, &sigcatch, &wchan ); processnum = processnum.rightJustify( 5, ' ' ); QString processcmd = QString( comm ).replace( QRegExp( "[()]" ), "" ); QString processstatus = QChar(state); QString processtime = QString::number( ( utime + stime ) / 100 ); processtime = processtime.rightJustify( 9, ' ' ); fclose( procfile ); newitem = new QListViewItem( ProcessView, processnum, processcmd, processstatus, processtime ); if ( processnum == selectedpid ) { selecteditem = newitem; } } } } ProcessView->setCurrentItem( selecteditem ); } delete proclist; delete procdir; } void ProcessInfo::slotSendClicked() { QListViewItem *currprocess = ProcessView->currentItem(); if ( !currprocess ) { return; } QString capstr = tr( "You really want to send\n" ); capstr.append( SignalCB->currentText() ); capstr.append( "\nto this process?" ); - if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, - QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) + if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, + QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) { - QString sigstr = SignalCB->currentText(); - sigstr.truncate(2); - int sigid = sigstr.toUInt(); - kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); + currprocess = ProcessView->currentItem(); + if ( currprocess ) + { + QString sigstr = SignalCB->currentText(); + sigstr.truncate(2); + int sigid = sigstr.toUInt(); + kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ); + } } } void ProcessInfo::viewProcess( QListViewItem *process ) { QString pid= process->text( 0 ).stripWhiteSpace(); QString command = process->text( 1 ); ProcessDtl->setCaption( pid + " - " + command ); FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); if ( statfile ) { char line[81]; fgets( line, 81, statfile ); ProcessDtl->detailView->setText( line ); while ( fgets( line, 81, statfile ) ) { ProcessDtl->detailView->append( line ); } fclose( statfile ); } ProcessDtl->showMaximized(); } |