summaryrefslogtreecommitdiff
authormickeyl <mickeyl>2004-01-13 20:03:55 (UTC)
committer mickeyl <mickeyl>2004-01-13 20:03:55 (UTC)
commita730fd614ed213ca590ae075ed99feec65522868 (patch) (unidiff)
tree072f5342fc43c4cd5acf9620a150bd9247469f91
parente117e8427cd8bcd0ab1a74abdc5cd4ab12654194 (diff)
downloadopie-a730fd614ed213ca590ae075ed99feec65522868.zip
opie-a730fd614ed213ca590ae075ed99feec65522868.tar.gz
opie-a730fd614ed213ca590ae075ed99feec65522868.tar.bz2
use OProcess::processPID()
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/net/wellenreiter/gui/main.cpp32
1 files changed, 4 insertions, 28 deletions
diff --git a/noncore/net/wellenreiter/gui/main.cpp b/noncore/net/wellenreiter/gui/main.cpp
index 702a7cc..d32b362 100644
--- a/noncore/net/wellenreiter/gui/main.cpp
+++ b/noncore/net/wellenreiter/gui/main.cpp
@@ -1,5 +1,5 @@
1/********************************************************************** 1/**********************************************************************
2** Copyright (C) 2002 Michael 'Mickey' Lauer. All rights reserved. 2** Copyright (C) 2002-2004 Michael 'Mickey' Lauer. All rights reserved.
3** 3**
4** This file is part of Opie Environment. 4** This file is part of Opie Environment.
5** 5**
@@ -16,6 +16,7 @@
16#include "mainwindow.h" 16#include "mainwindow.h"
17#ifdef QWS 17#ifdef QWS
18#include <opie2/oapplication.h> 18#include <opie2/oapplication.h>
19#include <opie2/oprocess.h>
19#else 20#else
20#include <qapplication.h> 21#include <qapplication.h>
21#endif 22#endif
@@ -23,12 +24,6 @@
23#include <qmessagebox.h> 24#include <qmessagebox.h>
24#include <qstringlist.h> 25#include <qstringlist.h>
25 26
26// ==> OProcess
27#include <qdir.h>
28#include <qfileinfo.h>
29#include <qregexp.h>
30#include <qtextstream.h>
31
32#include <errno.h> 27#include <errno.h>
33#include <signal.h> 28#include <signal.h>
34#include <string.h> 29#include <string.h>
@@ -77,33 +72,14 @@ int main( int argc, char **argv )
77 if ( result == QMessageBox::No ) return -1; 72 if ( result == QMessageBox::No ) return -1;
78 } 73 }
79 74
80 // dhcp check - NOT HERE! This really belongs as a static member to OProcess 75 if ( OProcess::processPID( "dhcpc" ) )
81 // and I want to call it like that: if ( OProcess::isRunning( QString& ) ) ...
82
83 QString line;
84 QDir d = QDir( "/proc" );
85 QStringList dirs = d.entryList( QDir::Dirs );
86 QStringList::Iterator it;
87 for ( it = dirs.begin(); it != dirs.end(); ++it )
88 {
89 //qDebug( "next entry: %s", (const char*) *it );
90 QFile file( "/proc/"+*it+"/cmdline" );
91 file.open( IO_ReadOnly );
92 if ( !file.isOpen() ) continue;
93 QTextStream t( &file );
94 line = t.readLine();
95 //qDebug( "cmdline = %s", (const char*) line );
96 if ( line.contains( "dhcp" ) ) break;
97 }
98 if ( line.contains( "dhcp" ) )
99 { 76 {
100 qWarning( "Wellenreiter: found dhcp process #%d", (*it).toInt() );
101 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n" 77 result = QMessageBox::warning( w, " - Wellenreiter II - (dhcp)", QObject::tr( "You have a dhcp client running.\n"
102 "This can severly limit scanning!\nShould I kill it for you?" ), 78 "This can severly limit scanning!\nShould I kill it for you?" ),
103 QMessageBox::Yes, QMessageBox::No ); 79 QMessageBox::Yes, QMessageBox::No );
104 if ( result == QMessageBox::Yes ) 80 if ( result == QMessageBox::Yes )
105 { 81 {
106 if ( -1 == ::kill( (*it).toInt(), SIGTERM ) ) 82 if ( -1 == ::kill( OProcess::processPID( "dhcpc" ), SIGTERM ) )
107 qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) ); 83 qWarning( "Wellenreiter: can't kill process #%d (%s)", result, strerror( errno ) );
108 else 84 else
109 killed = true; 85 killed = true;