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.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp
index b3f9724..56f9883 100644
--- a/libopie2/opiecore/oprocess.cpp
+++ b/libopie2/opiecore/oprocess.cpp
@@ -883,69 +883,69 @@ QCString OProcess::searchShell()
883 return tmpShell; 883 return tmpShell;
884} 884}
885 885
886bool OProcess::isExecutable( const QCString &filename ) 886bool OProcess::isExecutable( const QCString &filename )
887{ 887{
888 struct stat fileinfo; 888 struct stat fileinfo;
889 889
890 if ( filename.isEmpty() ) 890 if ( filename.isEmpty() )
891 return false; 891 return false;
892 892
893 // CC: we've got a valid filename, now let's see whether we can execute that file 893 // CC: we've got a valid filename, now let's see whether we can execute that file
894 894
895 if ( -1 == stat( filename.data(), &fileinfo ) ) 895 if ( -1 == stat( filename.data(), &fileinfo ) )
896 return false; 896 return false;
897 // CC: return false if the file does not exist 897 // CC: return false if the file does not exist
898 898
899 // CC: anyway, we cannot execute directories, block/character devices, fifos or sockets 899 // CC: anyway, we cannot execute directories, block/character devices, fifos or sockets
900 if ( ( S_ISDIR( fileinfo.st_mode ) ) || 900 if ( ( S_ISDIR( fileinfo.st_mode ) ) ||
901 ( S_ISCHR( fileinfo.st_mode ) ) || 901 ( S_ISCHR( fileinfo.st_mode ) ) ||
902 ( S_ISBLK( fileinfo.st_mode ) ) || 902 ( S_ISBLK( fileinfo.st_mode ) ) ||
903#ifdef S_ISSOCK 903#ifdef S_ISSOCK
904 // CC: SYSVR4 systems don't have that macro 904 // CC: SYSVR4 systems don't have that macro
905 ( S_ISSOCK( fileinfo.st_mode ) ) || 905 ( S_ISSOCK( fileinfo.st_mode ) ) ||
906#endif 906#endif
907 ( S_ISFIFO( fileinfo.st_mode ) ) || 907 ( S_ISFIFO( fileinfo.st_mode ) ) ||
908 ( S_ISDIR( fileinfo.st_mode ) ) ) 908 ( S_ISDIR( fileinfo.st_mode ) ) )
909 { 909 {
910 return false; 910 return false;
911 } 911 }
912 912
913 // CC: now check for permission to execute the file 913 // CC: now check for permission to execute the file
914 if ( access( filename.data(), X_OK ) != 0 ) 914 if ( access( filename.data(), X_OK ) != 0 )
915 return false; 915 return false;
916 916
917 // CC: we've passed all the tests... 917 // CC: we've passed all the tests...
918 return true; 918 return true;
919} 919}
920 920
921int OProcess::processPID( const QString& process ) 921int OProcess::processPID( const QString& process )
922{ 922{
923 QString line; 923 QString line;
924 QDir d = QDir( "/proc" ); 924 QDir d = QDir( "/proc" );
925 QStringList dirs = d.entryList( QDir::Dirs ); 925 QStringList dirs = d.entryList( QDir::Dirs );
926 QStringList::Iterator it; 926 QStringList::Iterator it;
927 for ( it = dirs.begin(); it != dirs.end(); ++it ) 927 for ( it = dirs.begin(); it != dirs.end(); ++it )
928 { 928 {
929 //qDebug( "next entry: %s", (const char*) *it ); 929 //qDebug( "next entry: %s", (const char*) *it );
930 QFile file( "/proc/"+*it+"/cmdline" ); 930 QFile file( "/proc/"+*it+"/cmdline" );
931 file.open( IO_ReadOnly ); 931 if ( !file.open( IO_ReadOnly ) ) continue;
932 if ( !file.isOpen() ) continue; 932 if ( !file.isOpen() ) continue;
933 QTextStream t( &file ); 933 QTextStream t( &file );
934 line = t.readLine(); 934 line = t.readLine();
935 //qDebug( "cmdline = %s", (const char*) line ); 935 //qDebug( "cmdline = %s", (const char*) line );
936 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 ;)
937 } 937 }
938 if ( line.contains( process ) ) 938 if ( line.contains( process ) )
939 { 939 {
940 //qDebug( "found process id #%d", (*it).toInt() ); 940 //qDebug( "found process id #%d", (*it).toInt() );
941 return (*it).toInt(); 941 return (*it).toInt();
942 } 942 }
943 else 943 else
944 { 944 {
945 //qDebug( "process '%s' not found", (const char*) process ); 945 //qDebug( "process '%s' not found", (const char*) process );
946 return 0; 946 return 0;
947 } 947 }
948} 948}
949 949
950} 950}
951} 951}