author | mickeyl <mickeyl> | 2004-02-15 18:22:15 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-02-15 18:22:15 (UTC) |
commit | 842923f72761677ea132c16a23091c5ee3a35780 (patch) (unidiff) | |
tree | 0b2995c8f4d87b7f6570d551c71f5c3aa4307f24 /libopie2 | |
parent | 4d467f290f7f42717be14bb0f269570fe5dd07bc (diff) | |
download | opie-842923f72761677ea132c16a23091c5ee3a35780.zip opie-842923f72761677ea132c16a23091c5ee3a35780.tar.gz opie-842923f72761677ea132c16a23091c5ee3a35780.tar.bz2 |
better return 0 here
-rw-r--r-- | libopie2/opiecore/oprocess.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/oprocess.cpp b/libopie2/opiecore/oprocess.cpp index 5cfcf32..83677aa 100644 --- a/libopie2/opiecore/oprocess.cpp +++ b/libopie2/opiecore/oprocess.cpp | |||
@@ -847,99 +847,99 @@ void OProcess::commClose() | |||
847 | close( err[ 0 ] ); | 847 | close( err[ 0 ] ); |
848 | } | 848 | } |
849 | } | 849 | } |
850 | } | 850 | } |
851 | 851 | ||
852 | void OProcess::setUseShell( bool useShell, const char *shell ) | 852 | void OProcess::setUseShell( bool useShell, const char *shell ) |
853 | { | 853 | { |
854 | if ( !d ) | 854 | if ( !d ) |
855 | d = new OProcessPrivate; | 855 | d = new OProcessPrivate; |
856 | d->useShell = useShell; | 856 | d->useShell = useShell; |
857 | d->shell = shell; | 857 | d->shell = shell; |
858 | if ( d->shell.isEmpty() ) | 858 | if ( d->shell.isEmpty() ) |
859 | d->shell = searchShell(); | 859 | d->shell = searchShell(); |
860 | } | 860 | } |
861 | 861 | ||
862 | QString OProcess::quote( const QString &arg ) | 862 | QString OProcess::quote( const QString &arg ) |
863 | { | 863 | { |
864 | QString res = arg; | 864 | QString res = arg; |
865 | res.replace( QRegExp( QString::fromLatin1( "\'" ) ), | 865 | res.replace( QRegExp( QString::fromLatin1( "\'" ) ), |
866 | QString::fromLatin1( "'\"'\"'" ) ); | 866 | QString::fromLatin1( "'\"'\"'" ) ); |
867 | res.prepend( '\'' ); | 867 | res.prepend( '\'' ); |
868 | res.append( '\'' ); | 868 | res.append( '\'' ); |
869 | return res; | 869 | return res; |
870 | } | 870 | } |
871 | 871 | ||
872 | QCString OProcess::searchShell() | 872 | QCString OProcess::searchShell() |
873 | { | 873 | { |
874 | QCString tmpShell = QCString( getenv( "SHELL" ) ).stripWhiteSpace(); | 874 | QCString tmpShell = QCString( getenv( "SHELL" ) ).stripWhiteSpace(); |
875 | if ( !isExecutable( tmpShell ) ) | 875 | if ( !isExecutable( tmpShell ) ) |
876 | { | 876 | { |
877 | tmpShell = "/bin/sh"; | 877 | tmpShell = "/bin/sh"; |
878 | } | 878 | } |
879 | 879 | ||
880 | return tmpShell; | 880 | return tmpShell; |
881 | } | 881 | } |
882 | 882 | ||
883 | bool OProcess::isExecutable( const QCString &filename ) | 883 | bool OProcess::isExecutable( const QCString &filename ) |
884 | { | 884 | { |
885 | struct stat fileinfo; | 885 | struct stat fileinfo; |
886 | 886 | ||
887 | if ( filename.isEmpty() ) | 887 | if ( filename.isEmpty() ) |
888 | return false; | 888 | return false; |
889 | 889 | ||
890 | // CC: we've got a valid filename, now let's see whether we can execute that file | 890 | // CC: we've got a valid filename, now let's see whether we can execute that file |
891 | 891 | ||
892 | if ( -1 == stat( filename.data(), &fileinfo ) ) | 892 | if ( -1 == stat( filename.data(), &fileinfo ) ) |
893 | return false; | 893 | return false; |
894 | // CC: return false if the file does not exist | 894 | // CC: return false if the file does not exist |
895 | 895 | ||
896 | // CC: anyway, we cannot execute directories, block/character devices, fifos or sockets | 896 | // CC: anyway, we cannot execute directories, block/character devices, fifos or sockets |
897 | if ( ( S_ISDIR( fileinfo.st_mode ) ) || | 897 | if ( ( S_ISDIR( fileinfo.st_mode ) ) || |
898 | ( S_ISCHR( fileinfo.st_mode ) ) || | 898 | ( S_ISCHR( fileinfo.st_mode ) ) || |
899 | ( S_ISBLK( fileinfo.st_mode ) ) || | 899 | ( S_ISBLK( fileinfo.st_mode ) ) || |
900 | #ifdef S_ISSOCK | 900 | #ifdef S_ISSOCK |
901 | // CC: SYSVR4 systems don't have that macro | 901 | // CC: SYSVR4 systems don't have that macro |
902 | ( S_ISSOCK( fileinfo.st_mode ) ) || | 902 | ( S_ISSOCK( fileinfo.st_mode ) ) || |
903 | #endif | 903 | #endif |
904 | ( S_ISFIFO( fileinfo.st_mode ) ) || | 904 | ( S_ISFIFO( fileinfo.st_mode ) ) || |
905 | ( S_ISDIR( fileinfo.st_mode ) ) ) | 905 | ( S_ISDIR( fileinfo.st_mode ) ) ) |
906 | { | 906 | { |
907 | return false; | 907 | return false; |
908 | } | 908 | } |
909 | 909 | ||
910 | // CC: now check for permission to execute the file | 910 | // CC: now check for permission to execute the file |
911 | if ( access( filename.data(), X_OK ) != 0 ) | 911 | if ( access( filename.data(), X_OK ) != 0 ) |
912 | return false; | 912 | return false; |
913 | 913 | ||
914 | // CC: we've passed all the tests... | 914 | // CC: we've passed all the tests... |
915 | return true; | 915 | return true; |
916 | } | 916 | } |
917 | 917 | ||
918 | int OProcess::processPID( const QString& process ) | 918 | int OProcess::processPID( const QString& process ) |
919 | { | 919 | { |
920 | QString line; | 920 | QString line; |
921 | QDir d = QDir( "/proc" ); | 921 | QDir d = QDir( "/proc" ); |
922 | QStringList dirs = d.entryList( QDir::Dirs ); | 922 | QStringList dirs = d.entryList( QDir::Dirs ); |
923 | QStringList::Iterator it; | 923 | QStringList::Iterator it; |
924 | for ( it = dirs.begin(); it != dirs.end(); ++it ) | 924 | for ( it = dirs.begin(); it != dirs.end(); ++it ) |
925 | { | 925 | { |
926 | //qDebug( "next entry: %s", (const char*) *it ); | 926 | //qDebug( "next entry: %s", (const char*) *it ); |
927 | QFile file( "/proc/"+*it+"/cmdline" ); | 927 | QFile file( "/proc/"+*it+"/cmdline" ); |
928 | file.open( IO_ReadOnly ); | 928 | file.open( IO_ReadOnly ); |
929 | if ( !file.isOpen() ) continue; | 929 | if ( !file.isOpen() ) continue; |
930 | QTextStream t( &file ); | 930 | QTextStream t( &file ); |
931 | line = t.readLine(); | 931 | line = t.readLine(); |
932 | //qDebug( "cmdline = %s", (const char*) line ); | 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 ;) | 933 | if ( line.contains( process ) ) break; //FIXME: That may find also other process, if the name is not long enough ;) |
934 | } | 934 | } |
935 | if ( line.contains( process ) ) | 935 | if ( line.contains( process ) ) |
936 | { | 936 | { |
937 | //qDebug( "found process id #%d", (*it).toInt() ); | 937 | //qDebug( "found process id #%d", (*it).toInt() ); |
938 | return (*it).toInt(); | 938 | return (*it).toInt(); |
939 | } | 939 | } |
940 | else | 940 | else |
941 | { | 941 | { |
942 | //qDebug( "process '%s' not found", (const char*) process ); | 942 | //qDebug( "process '%s' not found", (const char*) process ); |
943 | return -1; | 943 | return 0; |
944 | } | 944 | } |
945 | } | 945 | } |