summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/oprocess.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/oprocess.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/oprocess.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp
index 6349c83..dfde74a 100644
--- a/libopie2/opiecore/oprocess.cpp
+++ b/libopie2/opiecore/oprocess.cpp
@@ -40,60 +40,65 @@ _;:,     .>    :=|. This program is free software; you can
40#include <qmap.h> 40#include <qmap.h>
41#include <qsocketnotifier.h> 41#include <qsocketnotifier.h>
42#include <qtextstream.h> 42#include <qtextstream.h>
43 43
44/* STD */ 44/* STD */
45#include <errno.h> 45#include <errno.h>
46#include <fcntl.h> 46#include <fcntl.h>
47#include <pwd.h> 47#include <pwd.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <stdio.h> 50#include <stdio.h>
51#include <string.h> 51#include <string.h>
52#include <sys/time.h> 52#include <sys/time.h>
53#include <sys/types.h> 53#include <sys/types.h>
54#include <sys/stat.h> 54#include <sys/stat.h>
55#include <sys/socket.h> 55#include <sys/socket.h>
56#include <unistd.h> 56#include <unistd.h>
57#ifdef HAVE_SYS_SELECT_H 57#ifdef HAVE_SYS_SELECT_H
58#include <sys/select.h> 58#include <sys/select.h>
59#endif 59#endif
60#ifdef HAVE_INITGROUPS 60#ifdef HAVE_INITGROUPS
61#include <grp.h> 61#include <grp.h>
62#endif 62#endif
63 63
64using namespace Opie::Core::Private;
65
66namespace Opie {
67namespace Core {
68namespace Private {
64class OProcessPrivate 69class OProcessPrivate
65{ 70{
66public: 71public:
67 OProcessPrivate() : useShell( false ) 72 OProcessPrivate() : useShell( false )
68 { } 73 { }
69 74
70 bool useShell; 75 bool useShell;
71 QMap<QString, QString> env; 76 QMap<QString, QString> env;
72 QString wd; 77 QString wd;
73 QCString shell; 78 QCString shell;
74}; 79};
75 80}
76 81
77OProcess::OProcess( QObject *parent, const char *name ) 82OProcess::OProcess( QObject *parent, const char *name )
78 : QObject( parent, name ) 83 : QObject( parent, name )
79{ 84{
80 init ( ); 85 init ( );
81} 86}
82 87
83OProcess::OProcess( const QString &arg0, QObject *parent, const char *name ) 88OProcess::OProcess( const QString &arg0, QObject *parent, const char *name )
84 : QObject( parent, name ) 89 : QObject( parent, name )
85{ 90{
86 init ( ); 91 init ( );
87 *this << arg0; 92 *this << arg0;
88} 93}
89 94
90OProcess::OProcess( const QStringList &args, QObject *parent, const char *name ) 95OProcess::OProcess( const QStringList &args, QObject *parent, const char *name )
91 : QObject( parent, name ) 96 : QObject( parent, name )
92{ 97{
93 init ( ); 98 init ( );
94 *this << args; 99 *this << args;
95} 100}
96 101
97void OProcess::init ( ) 102void OProcess::init ( )
98{ 103{
99 run_mode = NotifyOnExit; 104 run_mode = NotifyOnExit;
@@ -920,24 +925,27 @@ int OProcess::processPID( const QString& process )
920 QStringList dirs = d.entryList( QDir::Dirs ); 925 QStringList dirs = d.entryList( QDir::Dirs );
921 QStringList::Iterator it; 926 QStringList::Iterator it;
922 for ( it = dirs.begin(); it != dirs.end(); ++it ) 927 for ( it = dirs.begin(); it != dirs.end(); ++it )
923 { 928 {
924 //qDebug( "next entry: %s", (const char*) *it ); 929 //qDebug( "next entry: %s", (const char*) *it );
925 QFile file( "/proc/"+*it+"/cmdline" ); 930 QFile file( "/proc/"+*it+"/cmdline" );
926 file.open( IO_ReadOnly ); 931 file.open( IO_ReadOnly );
927 if ( !file.isOpen() ) continue; 932 if ( !file.isOpen() ) continue;
928 QTextStream t( &file ); 933 QTextStream t( &file );
929 line = t.readLine(); 934 line = t.readLine();
930 //qDebug( "cmdline = %s", (const char*) line ); 935 //qDebug( "cmdline = %s", (const char*) line );
931 if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;) 936 if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;)
932 } 937 }
933 if ( line.contains( process ) ) 938 if ( line.contains( process ) )
934 { 939 {
935 //qDebug( "found process id #%d", (*it).toInt() ); 940 //qDebug( "found process id #%d", (*it).toInt() );
936 return (*it).toInt(); 941 return (*it).toInt();
937 } 942 }
938 else 943 else
939 { 944 {
940 //qDebug( "process '%s' not found", (const char*) process ); 945 //qDebug( "process '%s' not found", (const char*) process );
941 return 0; 946 return 0;
942 } 947 }
943} 948}
949
950}
951}