Darrell Anderson 12 years ago
commit a41c85f0d7

@ -17,6 +17,7 @@ License. See the file "COPYING" for the exact licensing terms.
#include <tqpainter.h> #include <tqpainter.h>
#include <tqdatetime.h> #include <tqdatetime.h>
#include <tqimage.h> #include <tqimage.h>
#include <tqfile.h>
#include <kprocess.h> #include <kprocess.h>
#include <unistd.h> #include <unistd.h>
#include <kstandarddirs.h> #include <kstandarddirs.h>
@ -1855,26 +1856,17 @@ bool Client::isSuspendable() const
} }
else else
{ {
FILE *procfile; TQFile procStatFile(TQString("/proc/%1/stat").arg(pid));
if(chdir(TQString("/proc/%1").arg(pid).ascii()) == 0) if (procStatFile.open(IO_ReadOnly))
{ {
procfile = fopen("stat", "r"); TQByteArray statRaw = procStatFile.readAll();
} procStatFile.close();
if(!procfile) TQString statString(statRaw);
{ TQStringList statFields = TQStringList::split(" ", statString, TRUE);
return false; TQString tcomm = statFields[1];
} TQString state = statFields[2];
else if( state != "T" )
{
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' )
{ {
fclose(procfile);
// Make sure no windows of this process are special // Make sure no windows of this process are special
for ( ClientList::ConstIterator it = workspace()->clients.begin(); it != workspace()->clients.end(); ++it) for ( ClientList::ConstIterator it = workspace()->clients.begin(); it != workspace()->clients.end(); ++it)
{ {
@ -1902,10 +1894,13 @@ bool Client::isSuspendable() const
} }
else else
{ {
fclose(procfile);
return false; return false;
} }
} }
else
{
return false;
}
} }
} }
@ -1922,34 +1917,28 @@ bool Client::isResumeable() const
} }
else else
{ {
FILE *procfile; TQFile procStatFile(TQString("/proc/%1/stat").arg(pid));
if(chdir(TQString("/proc/%1").arg(pid).ascii()) == 0) if (procStatFile.open(IO_ReadOnly))
{ {
procfile = fopen("stat", "r"); TQByteArray statRaw = procStatFile.readAll();
} procStatFile.close();
if(!procfile) TQString statString(statRaw);
{ TQStringList statFields = TQStringList::split(" ", statString, TRUE);
return false; TQString tcomm = statFields[1];
} TQString state = statFields[2];
else if( state == "T" )
{
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' )
{ {
fclose(procfile);
return true; return true;
} }
else else
{ {
fclose(procfile);
return false; return false;
} }
} }
else
{
return false;
}
} }
} }

Loading…
Cancel
Save