Diffstat (limited to 'noncore/settings/sysinfo/processinfo.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 4ecb704..225da63 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -20,37 +20,32 @@ | |||
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 | #include <qmessagebox.h> | ||
27 | |||
28 | #include <sys/types.h> | ||
29 | #include <signal.h> | ||
30 | 26 | ||
31 | #include "processinfo.h" | 27 | #include "processinfo.h" |
28 | #include "processdetail.h" | ||
32 | 29 | ||
33 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | 30 | ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) |
34 | : QWidget( parent, name, fl ) | 31 | : QWidget( parent, name, fl ) |
35 | { | 32 | { |
36 | QVBoxLayout *vb = new QVBoxLayout( this, 5 ); | 33 | QVBoxLayout *layout = new QVBoxLayout( this, 5 ); |
37 | 34 | ||
38 | ProcessView = new QListView( this, "ProcessView" ); | 35 | ProcessView = new QListView( this, "ProcessView" ); |
39 | int colnum = ProcessView->addColumn( tr( "PID" ) ); | 36 | int colnum = ProcessView->addColumn( tr( "PID" ) ); |
40 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 37 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
41 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); | 38 | colnum = ProcessView->addColumn( tr( "Command" ),96 ); |
42 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | ||
43 | colnum = ProcessView->addColumn( tr( "Status" ) ); | 39 | colnum = ProcessView->addColumn( tr( "Status" ) ); |
44 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | ||
45 | colnum = ProcessView->addColumn( tr( "Time" ) ); | 40 | colnum = ProcessView->addColumn( tr( "Time" ) ); |
46 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 41 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
47 | ProcessView->setAllColumnsShowFocus( TRUE ); | 42 | ProcessView->setAllColumnsShowFocus( TRUE ); |
48 | connect( ProcessView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( viewProcess(QListViewItem *) ) ); | 43 | connect( ProcessView, SIGNAL( doubleClicked(QListViewItem *) ), this, SLOT( viewProcess(QListViewItem *) ) ); |
49 | 44 | ||
50 | vb->addWidget( ProcessView ); | 45 | layout->addWidget( ProcessView ); |
51 | 46 | ||
52 | QTimer *t = new QTimer( this ); | 47 | QTimer *t = new QTimer( this ); |
53 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 48 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
54 | t->start( 5000 ); | 49 | t->start( 5000 ); |
55 | 50 | ||
56 | updateData(); | 51 | updateData(); |
@@ -116,24 +111,27 @@ void ProcessInfo::updateData() | |||
116 | delete proclist; | 111 | delete proclist; |
117 | delete procdir; | 112 | delete procdir; |
118 | } | 113 | } |
119 | 114 | ||
120 | void ProcessInfo::viewProcess(QListViewItem *process) | 115 | void ProcessInfo::viewProcess(QListViewItem *process) |
121 | { | 116 | { |
122 | QString pid= process->text(0); | 117 | QString pid= process->text(0).stripWhiteSpace(); |
123 | QString command = process->text(1); | 118 | QString command = process->text(1); |
124 | switch( QMessageBox::information( this, (tr("Kill Process?")), | 119 | ProcessDetail *processdtl = new ProcessDetail( this, 0, TRUE, 0); |
125 | (tr("You really want to kill\n"+command+" PID: "+pid+"?")), | 120 | processdtl->setCaption( pid + " - " + command ); |
126 | (tr("Yes")), (tr("No")), 0 )){ | 121 | processdtl->pid = pid.toUInt(); |
127 | case 0: // Yes clicked, | 122 | processdtl->ProcessView->setTextFormat( RichText ); |
123 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); | ||
124 | if ( statfile ) | ||
125 | { | ||
126 | char line[81]; | ||
127 | fgets( line, 81, statfile ); | ||
128 | processdtl->ProcessView->setText( line ); | ||
129 | while ( fgets( line, 81, statfile ) ) | ||
128 | { | 130 | { |
129 | bool ok; | 131 | processdtl->ProcessView->append( line ); |
130 | pid_t child=pid.toInt(&ok,10); | 132 | } |
131 | if((kill(child,SIGKILL)) < 0) | 133 | fclose( statfile ); |
132 | perror("kill:SIGKILL"); | 134 | } |
133 | } | 135 | |
134 | break; | 136 | processdtl->showMaximized(); |
135 | case 1: // Cancel | ||
136 | break; | ||
137 | }; | ||
138 | //printf("Double click for PID: %s\n", process->text(0).stripWhiteSpace().latin1()); | ||
139 | } | 137 | } |