author | drw <drw> | 2002-12-20 02:17:55 (UTC) |
---|---|---|
committer | drw <drw> | 2002-12-20 02:17:55 (UTC) |
commit | 9328bf79f49294e14c1753c9ee17ddd2985c1969 (patch) (unidiff) | |
tree | b0c9fa3e990b45cbfc9fb7fb33da73b9f6477df9 | |
parent | 3e556ed5f8c8b1236b9c6155b609930103d17b21 (diff) | |
download | opie-9328bf79f49294e14c1753c9ee17ddd2985c1969.zip opie-9328bf79f49294e14c1753c9ee17ddd2985c1969.tar.gz opie-9328bf79f49294e14c1753c9ee17ddd2985c1969.tar.bz2 |
Fix to prevent segfault when no process/module is selected in list.
-rw-r--r-- | noncore/settings/sysinfo/modulesinfo.cpp | 5 | ||||
-rw-r--r-- | noncore/settings/sysinfo/processinfo.cpp | 7 |
2 files changed, 11 insertions, 1 deletions
diff --git a/noncore/settings/sysinfo/modulesinfo.cpp b/noncore/settings/sysinfo/modulesinfo.cpp index 8b58fe9..29cce90 100644 --- a/noncore/settings/sysinfo/modulesinfo.cpp +++ b/noncore/settings/sysinfo/modulesinfo.cpp | |||
@@ -29,146 +29,151 @@ | |||
29 | #include <qmessagebox.h> | 29 | #include <qmessagebox.h> |
30 | #include <qpushbutton.h> | 30 | #include <qpushbutton.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qtimer.h> | 32 | #include <qtimer.h> |
33 | #include <qwhatsthis.h> | 33 | #include <qwhatsthis.h> |
34 | 34 | ||
35 | #include "modulesinfo.h" | 35 | #include "modulesinfo.h" |
36 | #include "detail.h" | 36 | #include "detail.h" |
37 | 37 | ||
38 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) | 38 | ModulesInfo::ModulesInfo( QWidget* parent, const char* name, WFlags fl ) |
39 | : QWidget( parent, name, fl ) | 39 | : QWidget( parent, name, fl ) |
40 | { | 40 | { |
41 | QGridLayout *layout = new QGridLayout( this ); | 41 | QGridLayout *layout = new QGridLayout( this ); |
42 | layout->setSpacing( 4 ); | 42 | layout->setSpacing( 4 ); |
43 | layout->setMargin( 4 ); | 43 | layout->setMargin( 4 ); |
44 | 44 | ||
45 | ModulesView = new QListView( this ); | 45 | ModulesView = new QListView( this ); |
46 | int colnum = ModulesView->addColumn( tr( "Module" ) ); | 46 | int colnum = ModulesView->addColumn( tr( "Module" ) ); |
47 | colnum = ModulesView->addColumn( tr( "Size" ) ); | 47 | colnum = ModulesView->addColumn( tr( "Size" ) ); |
48 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 48 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
49 | colnum = ModulesView->addColumn( tr( "Use#" ) ); | 49 | colnum = ModulesView->addColumn( tr( "Use#" ) ); |
50 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); | 50 | ModulesView->setColumnAlignment( colnum, Qt::AlignRight ); |
51 | colnum = ModulesView->addColumn( tr( "Used By" ) ); | 51 | colnum = ModulesView->addColumn( tr( "Used By" ) ); |
52 | ModulesView->setAllColumnsShowFocus( TRUE ); | 52 | ModulesView->setAllColumnsShowFocus( TRUE ); |
53 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); | 53 | layout->addMultiCellWidget( ModulesView, 0, 0, 0, 1 ); |
54 | QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); | 54 | QWhatsThis::add( ModulesView, tr( "This is a list of all the kernel modules currently loaded on this handheld device.\n\nClick and hold on a module to see additional information about the module, or to unload it." ) ); |
55 | 55 | ||
56 | // Test if we have /sbin/modinfo, and if so, allow module detail window | 56 | // Test if we have /sbin/modinfo, and if so, allow module detail window |
57 | if ( QFile::exists( "/sbin/modinfo" ) ) | 57 | if ( QFile::exists( "/sbin/modinfo" ) ) |
58 | { | 58 | { |
59 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); | 59 | QPEApplication::setStylusOperation( ModulesView->viewport(), QPEApplication::RightOnHold ); |
60 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 60 | connect( ModulesView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
61 | this, SLOT( viewModules( QListViewItem * ) ) ); | 61 | this, SLOT( viewModules( QListViewItem * ) ) ); |
62 | } | 62 | } |
63 | 63 | ||
64 | CommandCB = new QComboBox( FALSE, this ); | 64 | CommandCB = new QComboBox( FALSE, this ); |
65 | CommandCB->insertItem( "modprobe -r" ); | 65 | CommandCB->insertItem( "modprobe -r" ); |
66 | CommandCB->insertItem( "rmmod" ); | 66 | CommandCB->insertItem( "rmmod" ); |
67 | // I can't think of other useful commands yet. Anyone? | 67 | // I can't think of other useful commands yet. Anyone? |
68 | layout->addWidget( CommandCB, 1, 0 ); | 68 | layout->addWidget( CommandCB, 1, 0 ); |
69 | QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); | 69 | QWhatsThis::add( CommandCB, tr( "Select a command here and then click the Send button to the right to send the command to module selected above." ) ); |
70 | 70 | ||
71 | QPushButton *btn = new QPushButton( this ); | 71 | QPushButton *btn = new QPushButton( this ); |
72 | btn->setMinimumSize( QSize( 50, 24 ) ); | 72 | btn->setMinimumSize( QSize( 50, 24 ) ); |
73 | btn->setMaximumSize( QSize( 50, 24 ) ); | 73 | btn->setMaximumSize( QSize( 50, 24 ) ); |
74 | btn->setText( tr( "Send" ) ); | 74 | btn->setText( tr( "Send" ) ); |
75 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); | 75 | connect( btn, SIGNAL( clicked() ), this, SLOT( slotSendClicked() ) ); |
76 | layout->addWidget( btn, 1, 1 ); | 76 | layout->addWidget( btn, 1, 1 ); |
77 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); | 77 | QWhatsThis::add( btn, tr( "Click here to send the selected command to the module selected above." ) ); |
78 | 78 | ||
79 | QTimer *t = new QTimer( this ); | 79 | QTimer *t = new QTimer( this ); |
80 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); | 80 | connect( t, SIGNAL( timeout() ), this, SLOT( updateData() ) ); |
81 | t->start( 5000 ); | 81 | t->start( 5000 ); |
82 | 82 | ||
83 | updateData(); | 83 | updateData(); |
84 | 84 | ||
85 | ModulesDtl = new Detail(); | 85 | ModulesDtl = new Detail(); |
86 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); | 86 | QWhatsThis::add( ModulesDtl->detailView, tr( "This area shows detailed information about this module." ) ); |
87 | } | 87 | } |
88 | 88 | ||
89 | ModulesInfo::~ModulesInfo() | 89 | ModulesInfo::~ModulesInfo() |
90 | { | 90 | { |
91 | } | 91 | } |
92 | 92 | ||
93 | void ModulesInfo::updateData() | 93 | void ModulesInfo::updateData() |
94 | { | 94 | { |
95 | char modname[64]; | 95 | char modname[64]; |
96 | char usage[200]; | 96 | char usage[200]; |
97 | int modsize, usecount; | 97 | int modsize, usecount; |
98 | 98 | ||
99 | ModulesView->clear(); | 99 | ModulesView->clear(); |
100 | 100 | ||
101 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); | 101 | FILE *procfile = fopen( ( QString ) ( "/proc/modules"), "r"); |
102 | 102 | ||
103 | if ( procfile ) | 103 | if ( procfile ) |
104 | { | 104 | { |
105 | while ( true ) { | 105 | while ( true ) { |
106 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); | 106 | int success = fscanf( procfile, "%s%d%d%[^\n]", modname, &modsize, &usecount, usage ); |
107 | 107 | ||
108 | if ( success == EOF ) | 108 | if ( success == EOF ) |
109 | break; | 109 | break; |
110 | 110 | ||
111 | QString qmodname = QString( modname ); | 111 | QString qmodname = QString( modname ); |
112 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); | 112 | QString qmodsize = QString::number( modsize ).rightJustify( 6, ' ' ); |
113 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); | 113 | QString qusecount = QString::number( usecount ).rightJustify( 2, ' ' ); |
114 | QString qusage = QString( usage ); | 114 | QString qusage = QString( usage ); |
115 | 115 | ||
116 | ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); | 116 | ( void ) new QListViewItem( ModulesView, qmodname, qmodsize, qusecount, qusage ); |
117 | } | 117 | } |
118 | 118 | ||
119 | fclose( procfile ); | 119 | fclose( procfile ); |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
123 | void ModulesInfo::slotSendClicked() | 123 | void ModulesInfo::slotSendClicked() |
124 | { | 124 | { |
125 | if ( !ModulesView->currentItem() ) | ||
126 | { | ||
127 | return; | ||
128 | } | ||
129 | |||
125 | QString capstr = tr( "You really want to execute\n" ); | 130 | QString capstr = tr( "You really want to execute\n" ); |
126 | capstr.append( CommandCB->currentText() ); | 131 | capstr.append( CommandCB->currentText() ); |
127 | capstr.append( "\nfor this module?" ); | 132 | capstr.append( "\nfor this module?" ); |
128 | 133 | ||
129 | QString modname = ModulesView->currentItem()->text( 0 ); | 134 | QString modname = ModulesView->currentItem()->text( 0 ); |
130 | 135 | ||
131 | if ( QMessageBox::warning( this, modname, capstr, | 136 | if ( QMessageBox::warning( this, modname, capstr, |
132 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 137 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
133 | { | 138 | { |
134 | QString command = "/sbin/"; | 139 | QString command = "/sbin/"; |
135 | command.append( CommandCB->currentText() ); | 140 | command.append( CommandCB->currentText() ); |
136 | command.append( " " ); | 141 | command.append( " " ); |
137 | command.append( modname ); | 142 | command.append( modname ); |
138 | 143 | ||
139 | FILE* stream = popen( command, "r" ); | 144 | FILE* stream = popen( command, "r" ); |
140 | if ( stream ) | 145 | if ( stream ) |
141 | pclose( stream ); | 146 | pclose( stream ); |
142 | } | 147 | } |
143 | 148 | ||
144 | } | 149 | } |
145 | 150 | ||
146 | void ModulesInfo::viewModules( QListViewItem *modules ) | 151 | void ModulesInfo::viewModules( QListViewItem *modules ) |
147 | { | 152 | { |
148 | QString modname = modules->text( 0 ); | 153 | QString modname = modules->text( 0 ); |
149 | QString capstr = "Module: "; | 154 | QString capstr = "Module: "; |
150 | capstr.append( modname ); | 155 | capstr.append( modname ); |
151 | ModulesDtl->setCaption( capstr ); | 156 | ModulesDtl->setCaption( capstr ); |
152 | QString command = "/sbin/modinfo -nad "; | 157 | QString command = "/sbin/modinfo -nad "; |
153 | command.append( modname ); | 158 | command.append( modname ); |
154 | FILE* modinfo = popen( command, "r" ); | 159 | FILE* modinfo = popen( command, "r" ); |
155 | 160 | ||
156 | if ( modinfo ) | 161 | if ( modinfo ) |
157 | { | 162 | { |
158 | char line[200]; | 163 | char line[200]; |
159 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); | 164 | ModulesDtl->detailView->setText( " Details:\n------------\n" ); |
160 | 165 | ||
161 | while( true ) | 166 | while( true ) |
162 | { | 167 | { |
163 | int success = fscanf( modinfo, "%[^\n]\n", line ); | 168 | int success = fscanf( modinfo, "%[^\n]\n", line ); |
164 | if ( success == EOF ) | 169 | if ( success == EOF ) |
165 | break; | 170 | break; |
166 | ModulesDtl->detailView->append( line ); | 171 | ModulesDtl->detailView->append( line ); |
167 | } | 172 | } |
168 | 173 | ||
169 | pclose( modinfo ); | 174 | pclose( modinfo ); |
170 | } | 175 | } |
171 | 176 | ||
172 | ModulesDtl->showMaximized(); | 177 | ModulesDtl->showMaximized(); |
173 | } | 178 | } |
174 | 179 | ||
diff --git a/noncore/settings/sysinfo/processinfo.cpp b/noncore/settings/sysinfo/processinfo.cpp index 35d7ba1..9a5446a 100644 --- a/noncore/settings/sysinfo/processinfo.cpp +++ b/noncore/settings/sysinfo/processinfo.cpp | |||
@@ -51,135 +51,140 @@ ProcessInfo::ProcessInfo( QWidget* parent, const char* name, WFlags fl ) | |||
51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); | 51 | ProcessView->setColumnAlignment( colnum, Qt::AlignRight ); |
52 | ProcessView->setAllColumnsShowFocus( TRUE ); | 52 | ProcessView->setAllColumnsShowFocus( TRUE ); |
53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); | 53 | QPEApplication::setStylusOperation( ProcessView->viewport(), QPEApplication::RightOnHold ); |
54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), | 54 | connect( ProcessView, SIGNAL( rightButtonPressed( QListViewItem *, const QPoint &, int ) ), |
55 | this, SLOT( viewProcess( QListViewItem * ) ) ); | 55 | this, SLOT( viewProcess( QListViewItem * ) ) ); |
56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); | 56 | layout->addMultiCellWidget( ProcessView, 0, 0, 0, 1 ); |
57 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); | 57 | QWhatsThis::add( ProcessView, tr( "This is a list of all the processes on this handheld device.\n\nClick and hold on a process to see additional information about the process, or to send a signal to it." ) ); |
58 | 58 | ||
59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); | 59 | SignalCB = new QComboBox( FALSE, this, "SignalCB" ); |
60 | SignalCB->insertItem( " 1: SIGHUP" ); | 60 | SignalCB->insertItem( " 1: SIGHUP" ); |
61 | SignalCB->insertItem( " 2: SIGINT" ); | 61 | SignalCB->insertItem( " 2: SIGINT" ); |
62 | SignalCB->insertItem( " 3: SIGQUIT" ); | 62 | SignalCB->insertItem( " 3: SIGQUIT" ); |
63 | SignalCB->insertItem( " 5: SIGTRAP" ); | 63 | SignalCB->insertItem( " 5: SIGTRAP" ); |
64 | SignalCB->insertItem( " 6: SIGABRT" ); | 64 | SignalCB->insertItem( " 6: SIGABRT" ); |
65 | SignalCB->insertItem( " 9: SIGKILL" ); | 65 | SignalCB->insertItem( " 9: SIGKILL" ); |
66 | SignalCB->insertItem( "14: SIGALRM" ); | 66 | SignalCB->insertItem( "14: SIGALRM" ); |
67 | SignalCB->insertItem( "15: SIGTERM" ); | 67 | SignalCB->insertItem( "15: SIGTERM" ); |
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 | ||
91 | ProcessInfo::~ProcessInfo() | 91 | ProcessInfo::~ProcessInfo() |
92 | { | 92 | { |
93 | } | 93 | } |
94 | 94 | ||
95 | void ProcessInfo::updateData() | 95 | void 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 | ||
145 | void ProcessInfo::slotSendClicked() | 145 | void ProcessInfo::slotSendClicked() |
146 | { | 146 | { |
147 | QListViewItem *currprocess = ProcessView->currentItem(); | ||
148 | if ( !currprocess ) | ||
149 | { | ||
150 | return; | ||
151 | } | ||
152 | |||
147 | QString capstr = tr( "You really want to send\n" ); | 153 | QString capstr = tr( "You really want to send\n" ); |
148 | capstr.append( SignalCB->currentText() ); | 154 | capstr.append( SignalCB->currentText() ); |
149 | capstr.append( "\nto this process?" ); | 155 | capstr.append( "\nto this process?" ); |
150 | 156 | ||
151 | QListViewItem *currprocess = ProcessView->currentItem(); | ||
152 | 157 | ||
153 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, | 158 | if ( QMessageBox::warning( this, currprocess->text( 1 ), capstr, |
154 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) | 159 | QMessageBox::Yes | QMessageBox::Default, QMessageBox::No | QMessageBox::Escape ) == QMessageBox::Yes ) |
155 | { | 160 | { |
156 | QString sigstr = SignalCB->currentText(); | 161 | QString sigstr = SignalCB->currentText(); |
157 | sigstr.truncate(2); | 162 | sigstr.truncate(2); |
158 | int sigid = sigstr.toUInt(); | 163 | int sigid = sigstr.toUInt(); |
159 | if ( kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ) == 0 ) | 164 | if ( kill( currprocess->text( 0 ).stripWhiteSpace().toUInt(), sigid ) == 0 ) |
160 | { | 165 | { |
161 | hide(); | 166 | hide(); |
162 | } | 167 | } |
163 | } | 168 | } |
164 | 169 | ||
165 | } | 170 | } |
166 | 171 | ||
167 | void ProcessInfo::viewProcess( QListViewItem *process ) | 172 | void ProcessInfo::viewProcess( QListViewItem *process ) |
168 | { | 173 | { |
169 | QString pid= process->text( 0 ).stripWhiteSpace(); | 174 | QString pid= process->text( 0 ).stripWhiteSpace(); |
170 | QString command = process->text( 1 ); | 175 | QString command = process->text( 1 ); |
171 | ProcessDtl->setCaption( pid + " - " + command ); | 176 | ProcessDtl->setCaption( pid + " - " + command ); |
172 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); | 177 | FILE *statfile = fopen( ( QString ) ( "/proc/" + pid + "/status"), "r"); |
173 | if ( statfile ) | 178 | if ( statfile ) |
174 | { | 179 | { |
175 | char line[81]; | 180 | char line[81]; |
176 | fgets( line, 81, statfile ); | 181 | fgets( line, 81, statfile ); |
177 | ProcessDtl->detailView->setText( line ); | 182 | ProcessDtl->detailView->setText( line ); |
178 | while ( fgets( line, 81, statfile ) ) | 183 | while ( fgets( line, 81, statfile ) ) |
179 | { | 184 | { |
180 | ProcessDtl->detailView->append( line ); | 185 | ProcessDtl->detailView->append( line ); |
181 | } | 186 | } |
182 | fclose( statfile ); | 187 | fclose( statfile ); |
183 | } | 188 | } |
184 | ProcessDtl->showMaximized(); | 189 | ProcessDtl->showMaximized(); |
185 | } | 190 | } |