The hidden problem with using QProcess/KProcess in kdelibs...

Thiago Macieira thiago at
Sat Jan 22 20:55:56 GMT 2011

On Saturday, 22 de January de 2011 14:25:07 Dawit A wrote:
> Anyhow, this problem is not specific to VLC and can happen to any Qt
> application that blocks the SIGCHLD signals from reaching any of the
> threads. As such I think some action needs to be taken to address this
> issue. We can workaround this issue by unseting and setting the signal
> masks in the aforementioned function, but there are many other places
> in kdelibs where QProcess is used so perhaps a better resolution is
> needed for this ? Perhaps it is QProcess that should be taking care of
> this itself ?

I agree with you. QProcess relies on SIGCHLD being delivered to its signal 
handler. Unlike VLC, we don't try to mask it to one thread only. Instead, the 
signal handler function is written so that it can be run on any thread, and it 
signals an auxiliary thread (the QProcessManager thread) to do the non-async-
safe operations.

So for QProcess to work, it requires that people don't disrupt the above.

Setting signal masks is fine as long as you don't block it -- the signal 
handler will still be invoked in one thread. If you override with a different 
handler, then at least ensure Qt's is run.

If the code you pasted from VLC is run after QCoreApplication's constructor, 
the signal(SIGCHLD, SIG_DFL); call removes QProcessManager support.

QProcess could ensure that its handler is still in place before using them.

However, what I really want is that kernel developers give me a modern way of 
finding out a process has exited.

Thiago Macieira - thiago (AT) - thiago (AT)
  Senior Product Manager - Nokia, Qt Development Frameworks
      PGP/GPG: 0x6EF45358; fingerprint:
      E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
URL: <>

More information about the kde-core-devel mailing list