KProcess bug or something wrong in kdevelop?

Christoph Bartoschek bartoschek at gmx.de
Fri Nov 10 12:36:55 GMT 2006


Andreas Pakulat <apaku <at> gmx.de> writes:

> 
> Hi,
> 
> today I discovered a problem with KProcess. I need to use
> KProcess::Block to execute a qmake command and read the output on
> stderr. Figuring out how it should work was easy and actually it works
> 99%. The problem is that the remaining 1% creates a zombie process of
> whatever I start via KProcess, be it a shell command starting qmake,
> simply kcalc without shell or kate.
> 
> adymo and teatime tried to help me find out whats going on, but both
> gave up - they could reproduce the problem, though.
> 
> Another thing is that this only happens inside kdevelop (where I need
> the code), putting the same code into a simple kde app works perfectly.
> The same for a kpart-app according to teatime.

The problem is that you use QProcess and KProcess in the same process. Both 
install a signal handler for SIGCHLD and the second one overwrites the signal 
handler from the first one. Here is how the problem occurs on my machine:

1. A new instance of KProcessController is instantiated.
2. KProcessController::setupHandlers() is called and it sets a handler for 
SIGCHLD.
3. Someone uses QProcess and QProcessManager::QProcessManager() is called that 
installs a new handler for SIGCHLD.
4. KProcess is used again for the "qmake" call and it reuses the existing 
KProcessController.
5. qmake exits and SIGCHLD is generated
6. The handler used by QProcess is called and not the handler from 
KProcessController. 
7. The SIGCHLD is lost and KProcess is never notified that the child exited.


Greetings
Christoph





More information about the kde-core-devel mailing list