added an additional layer for process killing to musrgui/musredit which hopefully should help to reduce the number of musrfit/musrview corpses with high CPU load.

This commit is contained in:
nemu
2011-02-21 10:20:47 +00:00
parent 7fc76c7cb1
commit 076753e018
5 changed files with 27 additions and 12 deletions

View File

@@ -48,6 +48,7 @@ PFitOutputHandler::PFitOutputHandler(QString workingDirectory, QValueVector<QStr
fOutput = new QTextEdit( fVbox );
fOutput->setMinimumSize(800, 455);
fOutput->setReadOnly(true);
connect( fOutput, SIGNAL( destroyed() ), this, SLOT(quitButtonPressed() ) );
fQuitButton = new QPushButton( tr("Fitting..."), fVbox );
connect( fQuitButton, SIGNAL( clicked() ), this, SLOT( quitButtonPressed() ) );
resize( 800, 500 );
@@ -74,6 +75,7 @@ PFitOutputHandler::PFitOutputHandler(QString workingDirectory, QValueVector<QStr
tr("Quit") );
done(0);
}
fProcPID = fProc->processIdentifier();
}
//----------------------------------------------------------------------------------------------------
@@ -83,7 +85,13 @@ PFitOutputHandler::PFitOutputHandler(QString workingDirectory, QValueVector<QStr
PFitOutputHandler::~PFitOutputHandler()
{
if (fProc->isRunning()) {
fProc->kill();
fProc->tryTerminate();
QTimer::singleShot( 3000, fProc, SLOT( kill() ) );
}
if (fProc->isRunning()) { // try low level kill
char cmd[128];
sprintf(cmd, "kill -9 %ld", fProcPID);
system(cmd);
}
if (fProc) {
delete fProc;
@@ -130,11 +138,8 @@ void PFitOutputHandler::quitButtonPressed()
{
// if the fitting is still taking place, kill it
if (fProc->isRunning()) {
/*
fProc->tryTerminate();
QTimer::singleShot( 100, fProc, SLOT( kill() ) );
*/
fProc->kill();
QTimer::singleShot( 1000, fProc, SLOT( kill() ) );
}
accept();

View File

@@ -58,6 +58,7 @@ class PFitOutputHandler : public QDialog
virtual void processDone();
private:
Q_LONG fProcPID;
QProcess *fProc;
QVBox *fVbox;