QProcess::startDetached and bash stdout capture

Thiago Macieira thiago at kde.org
Sat Mar 25 16:01:49 GMT 2017


On sábado, 25 de março de 2017 08:50:37 PDT Thiago Macieira wrote:
> One problem is because the launched process inherits the pipes to stdout and
> stderr, but the shell sees the process group it launched exiting. It will
> probably close the pipe. Normally, this process would exit soon with
> SIGPIPE, but since a lot of code relating to sockets and pipes turns
> SIGPIPE off, it's possible that the detached process never receives SIGPIPE
> and simply remains forever.

Just found out that startDetached ignores SIGPIPE for all its child processes. 
And that has been there forever (see [1]). It's one of those old bug reports 
we used to get that the launched process received SIGPIPE after trying to 
write to stdout (like it should!) and then we decided to "help" the customer 
without understanding the issue properly.

The problem is that this is very common: launched processes often write 
debugging information to stderr... So we can't change it now. Instead, we 
could add a flag to startDetached and to indicate we should close stdin, stdout 
and stderr, reopening with /dev/null, and let SIGPIPE back to the default.

[1] http://code.qt.io/cgit/qt/qt.git/tree/src/corelib/io/qprocess_unix.cpp?
h=v4.5.1#n1316

-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel Open Source Technology Center





More information about the kde-core-devel mailing list