do not use fileno calls in forked child
authorJoerg Bornemann <joerg.bornemann@digia.com>
Thu, 6 Mar 2014 22:53:38 +0000 (23:53 +0100)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Thu, 13 Mar 2014 16:18:17 +0000 (17:18 +0100)
commit54491a2571669f0c232d2ab9926991ff9ecf3403
treee65a611ab1f945267a495d24eaf401452217618a
parent1f35d0783cc2a742d94d4f8e33819835dc990d87
do not use fileno calls in forked child

This fixes an issue that causes QProcess::start to silently fail on
OS X 10.9. Apparently, fileno(stdout) locks the handle on OS X 10.9.
It may happen that the parent process fflush()s stdout while the child
has just been forked. The stdout lock of the parent is never released
in the child and fileno(stdout) therefore locks forever.

According to the fork documentation on opengroup.org one may only call
async-signal-safe functions between fork and exec in the child. The
fileno() function does not appear in the list of async-signal-safe
functions. Also, fileno(stdout) and friends can be easily replaced by
the standard constants STDOUT_FILENO etc.

Done-with: Fawzi Mohamed <fawzi.mohamed@digia.com>
Task-number: QTBUG-37306

Change-Id: I2b1f5f47cc48a1ad020fb0493a955d2bc27aeb47
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
(cherry picked from qtbase/b2216bbe06b8be2bef6d8bc2ffff1337f6d23358)
src/corelib/io/qprocess_unix.cpp