diff options
author | Darrell Anderson <humanreadable@yahoo.com> | 2012-07-26 11:23:52 -0500 |
---|---|---|
committer | Darrell Anderson <humanreadable@yahoo.com> | 2012-07-26 11:23:52 -0500 |
commit | a41c85f0d728c560efa2bf9f9259f36bc4ce8dea (patch) | |
tree | aa1bf3b277f2f1adb5fc46faf953785c3d32a990 | |
parent | 52ec66bed1eab5739bedd9fdf1d0bde83e3801e4 (diff) | |
parent | c7ae64ef122b5c65137509a05692bc8d357a04f8 (diff) | |
download | tdebase-a41c85f0d728c560efa2bf9f9259f36bc4ce8dea.tar.gz tdebase-a41c85f0d728c560efa2bf9f9259f36bc4ce8dea.zip |
Merge branch 'master' of http://scm.trinitydesktop.org/scm/git/tdebase
-rw-r--r-- | twin/client.cpp | 65 |
1 files changed, 27 insertions, 38 deletions
diff --git a/twin/client.cpp b/twin/client.cpp index 749942643..35b588db5 100644 --- a/twin/client.cpp +++ b/twin/client.cpp @@ -17,6 +17,7 @@ License. See the file "COPYING" for the exact licensing terms. #include <tqpainter.h> #include <tqdatetime.h> #include <tqimage.h> +#include <tqfile.h> #include <kprocess.h> #include <unistd.h> #include <kstandarddirs.h> @@ -1855,26 +1856,17 @@ bool Client::isSuspendable() const } else { - FILE *procfile; - if(chdir(TQString("/proc/%1").arg(pid).ascii()) == 0) + TQFile procStatFile(TQString("/proc/%1/stat").arg(pid)); + if (procStatFile.open(IO_ReadOnly)) { - procfile = fopen("stat", "r"); - } - if(!procfile) - { - return false; - } - else - { - long long int procpid; - char tcomm[PATH_MAX]; - char state; - fscanf(procfile, "%lld ", &procpid); - fscanf(procfile, "%s ", tcomm); - fscanf(procfile, "%c ", &state); - if( state != 'T' ) + TQByteArray statRaw = procStatFile.readAll(); + procStatFile.close(); + TQString statString(statRaw); + TQStringList statFields = TQStringList::split(" ", statString, TRUE); + TQString tcomm = statFields[1]; + TQString state = statFields[2]; + if( state != "T" ) { - fclose(procfile); // Make sure no windows of this process are special for ( ClientList::ConstIterator it = workspace()->clients.begin(); it != workspace()->clients.end(); ++it) { @@ -1902,10 +1894,13 @@ bool Client::isSuspendable() const } else { - fclose(procfile); return false; } } + else + { + return false; + } } } @@ -1922,34 +1917,28 @@ bool Client::isResumeable() const } else { - FILE *procfile; - if(chdir(TQString("/proc/%1").arg(pid).ascii()) == 0) + TQFile procStatFile(TQString("/proc/%1/stat").arg(pid)); + if (procStatFile.open(IO_ReadOnly)) { - procfile = fopen("stat", "r"); - } - if(!procfile) - { - return false; - } - else - { - long long int procpid; - char tcomm[PATH_MAX]; - char state; - fscanf(procfile, "%lld ", &procpid); - fscanf(procfile, "%s ", tcomm); - fscanf(procfile, "%c ", &state); - if( state == 'T' ) + TQByteArray statRaw = procStatFile.readAll(); + procStatFile.close(); + TQString statString(statRaw); + TQStringList statFields = TQStringList::split(" ", statString, TRUE); + TQString tcomm = statFields[1]; + TQString state = statFields[2]; + if( state == "T" ) { - fclose(procfile); return true; } else { - fclose(procfile); return false; } } + else + { + return false; + } } } |