Diffstat (limited to 'libopie2/opiecore/oprocess.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/oprocess.cpp | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp index f1a5f3b..5cfcf32 100644 --- a/libopie2/opiecore/oprocess.cpp +++ b/libopie2/opiecore/oprocess.cpp | |||
@@ -33,16 +33,18 @@ _;:, .> :=|. This program is free software; you can | |||
33 | /* OPIE */ | 33 | /* OPIE */ |
34 | #include <opie2/oprocess.h> | 34 | #include <opie2/oprocess.h> |
35 | 35 | ||
36 | /* QT */ | 36 | /* QT */ |
37 | 37 | ||
38 | #include <qapplication.h> | 38 | #include <qapplication.h> |
39 | #include <qdir.h> | ||
39 | #include <qfile.h> | 40 | #include <qfile.h> |
40 | #include <qmap.h> | 41 | #include <qmap.h> |
41 | #include <qregexp.h> | 42 | #include <qregexp.h> |
42 | #include <qsocketnotifier.h> | 43 | #include <qsocketnotifier.h> |
44 | #include <qtextstream.h> | ||
43 | 45 | ||
44 | /* STD */ | 46 | /* STD */ |
45 | #include <errno.h> | 47 | #include <errno.h> |
46 | #include <fcntl.h> | 48 | #include <fcntl.h> |
47 | #include <pwd.h> | 49 | #include <pwd.h> |
48 | #include <stdlib.h> | 50 | #include <stdlib.h> |
@@ -910,6 +912,34 @@ bool OProcess::isExecutable( const QCString &filename ) | |||
910 | return false; | 912 | return false; |
911 | 913 | ||
912 | // CC: we've passed all the tests... | 914 | // CC: we've passed all the tests... |
913 | return true; | 915 | return true; |
914 | } | 916 | } |
915 | 917 | ||
918 | int OProcess::processPID( const QString& process ) | ||
919 | { | ||
920 | QString line; | ||
921 | QDir d = QDir( "/proc" ); | ||
922 | QStringList dirs = d.entryList( QDir::Dirs ); | ||
923 | QStringList::Iterator it; | ||
924 | for ( it = dirs.begin(); it != dirs.end(); ++it ) | ||
925 | { | ||
926 | //qDebug( "next entry: %s", (const char*) *it ); | ||
927 | QFile file( "/proc/"+*it+"/cmdline" ); | ||
928 | file.open( IO_ReadOnly ); | ||
929 | if ( !file.isOpen() ) continue; | ||
930 | QTextStream t( &file ); | ||
931 | line = t.readLine(); | ||
932 | //qDebug( "cmdline = %s", (const char*) line ); | ||
933 | if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;) | ||
934 | } | ||
935 | if ( line.contains( process ) ) | ||
936 | { | ||
937 | //qDebug( "found process id #%d", (*it).toInt() ); | ||
938 | return (*it).toInt(); | ||
939 | } | ||
940 | else | ||
941 | { | ||
942 | //qDebug( "process '%s' not found", (const char*) process ); | ||
943 | return -1; | ||
944 | } | ||
945 | } | ||