Fix "Can't stop kfind" bug.

We need to use /bin/sh as a shell and find process could be stopped.

svn path=/trunk/kdebase/kfind/; revision=37102
This commit is contained in:
Dima Rogozin 1999-12-21 23:05:02 +00:00
parent 2ea38a75ab
commit 33beb72ccf
2 changed files with 18 additions and 10 deletions

View file

@ -73,14 +73,19 @@ Kfind::Kfind( QWidget *parent, const char *name, const char *searchPath )
connect(parentWidget(),SIGNAL(unselectAll()),
win,SLOT(unselectAll()));
connect(&findProcess, SIGNAL(processExited(KProcess *)),
// We want to use /bin/sh as a shell. With tcsh and csh
// find process can not be stopped by kill() call.
findProcess = new KShellProcess("/bin/sh");
connect(findProcess, SIGNAL(processExited(KProcess *)),
this, SLOT(stopSearch()));
connect(&findProcess, SIGNAL(receivedStdout(KProcess *, char *, int)),
connect(findProcess, SIGNAL(receivedStdout(KProcess *, char *, int)),
this, SLOT(handleStdout(KProcess *, char *, int))) ;
}
Kfind::~Kfind() {
delete [] iBuffer;
delete findProcess;
}
void Kfind::startSearch() {
@ -107,9 +112,9 @@ void Kfind::startSearch() {
setExpanded(true);
findProcess.clearArguments ();
findProcess << cmdline;
findProcess.start(KProcess::NotifyOnExit, KProcess::AllOutput);
findProcess->clearArguments();
findProcess->setExecutable(cmdline);
findProcess->start(KProcess::NotifyOnExit, KProcess::AllOutput);
}
void Kfind::stopSearch() {
@ -118,10 +123,8 @@ void Kfind::stopSearch() {
win->endSearch();
tabWidget->endSearch();
if(findProcess.isRunning())
findProcess.kill();
if(findProcess->isRunning())
findProcess->kill();
setFocus();
}
@ -140,6 +143,11 @@ void Kfind::newSearch() {
}
void Kfind::handleStdout(KProcess *, char *buffer, int buflen) {
// If find process has been stopped ignore rest of the input
if(!findProcess->isRunning())
return;
// copy data to I/O buffer
int len = strlen(iBuffer);
memcpy(iBuffer + len, buffer, buflen);

View file

@ -48,7 +48,7 @@ signals:
protected:
private:
KShellProcess findProcess;
KShellProcess *findProcess;
KfindTabWidget *tabWidget;
KfindWindow * win;