diff options
author | Thiago Macieira <thiago.macieira@intel.com> | 2013-12-13 22:07:52 -0800 |
---|---|---|
committer | Thiago Macieira <thiago.macieira@intel.com> | 2015-01-23 19:13:17 +0100 |
commit | 1814142b7a11befab315bf3f9d91c4ffbf56ef3e (patch) | |
tree | 6cb50747f5b4b3a1251af3ba29c6f1194fbdbb46 /tests/auto/corelib | |
parent | f3459a43af8098d286ff272cc8da5e0c755d0700 (diff) |
Use forkfd in QProcess
Replace the existing code in QProcess that dealt with signaling of child
processes exiting with forkfd and spawnfd. The previous code was
convoluted and hard to maintain, having shown its age in the last
year. I've been running it for a year and a half and the new
implementation is definitely an improvement.
This change replaces support for the QNX Neutrino spawn() call with the
POSIX version. We lose the ability to do setsid(), but we gain quite a
few ioctls() that were done to fill in the file descriptor mapping
structure. That's also the only OS for which we have the ability to
thread-safely chdir() before the call to spawnfd().
Another advantage is that forkfd does not require a dedicated thread
running to handle child processes exiting.
Change-Id: I5eb76821dfdb6a8ed2989d7f53b3c31e515c3174
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Diffstat (limited to 'tests/auto/corelib')
-rw-r--r-- | tests/auto/corelib/io/qprocess/test/test.pro | 2 | ||||
-rw-r--r-- | tests/auto/corelib/io/qprocess/tst_qprocess.cpp | 22 |
2 files changed, 23 insertions, 1 deletions
diff --git a/tests/auto/corelib/io/qprocess/test/test.pro b/tests/auto/corelib/io/qprocess/test/test.pro index 90afeddaa0..f77dacc87b 100644 --- a/tests/auto/corelib/io/qprocess/test/test.pro +++ b/tests/auto/corelib/io/qprocess/test/test.pro @@ -1,7 +1,7 @@ CONFIG += testcase CONFIG += parallel_test CONFIG -= app_bundle debug_and_release_target -QT = core testlib network +QT = core-private testlib network SOURCES = ../tst_qprocess.cpp TARGET = ../tst_qprocess diff --git a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp index c8ba69c0fb..3866dd246b 100644 --- a/tests/auto/corelib/io/qprocess/tst_qprocess.cpp +++ b/tests/auto/corelib/io/qprocess/tst_qprocess.cpp @@ -44,6 +44,7 @@ #include <stdlib.h> #ifndef QT_NO_PROCESS +# include <private/qprocess_p.h> // only so we get QPROCESS_USE_SPAWN # if defined(Q_OS_WIN) # include <windows.h> # endif @@ -316,6 +317,9 @@ void tst_QProcess::execute() { QCOMPARE(QProcess::execute("testProcessNormal/testProcessNormal", QStringList() << "arg1" << "arg2"), 0); +#ifdef QPROCESS_USE_SPAWN + QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue); +#endif QCOMPARE(QProcess::execute("nonexistingexe"), -2); } @@ -325,6 +329,9 @@ void tst_QProcess::startDetached() QProcess proc; QVERIFY(proc.startDetached("testProcessNormal/testProcessNormal", QStringList() << "arg1" << "arg2")); +#ifdef QPROCESS_USE_SPAWN + QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Continue); +#endif QCOMPARE(QProcess::startDetached("nonexistingexe"), false); } @@ -713,6 +720,9 @@ void tst_QProcess::waitForFinished() QCOMPARE(output.count("\n"), 10*1024); process.start("blurdybloop"); +#ifdef QPROCESS_USE_SPAWN + QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Abort); +#endif QVERIFY(!process.waitForFinished()); QCOMPARE(process.error(), QProcess::FailedToStart); } @@ -1528,6 +1538,9 @@ void tst_QProcess::exitCodeTest() //----------------------------------------------------------------------------- void tst_QProcess::failToStart() { +#ifdef QPROCESS_USE_SPAWN + QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); +#endif qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); qRegisterMetaType<QProcess::ProcessState>("QProcess::ProcessState"); @@ -1595,6 +1608,9 @@ void tst_QProcess::failToStart() //----------------------------------------------------------------------------- void tst_QProcess::failToStartWithWait() { +#ifdef QPROCESS_USE_SPAWN + QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); +#endif qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); @@ -1622,6 +1638,9 @@ void tst_QProcess::failToStartWithWait() //----------------------------------------------------------------------------- void tst_QProcess::failToStartWithEventLoop() { +#ifdef QPROCESS_USE_SPAWN + QSKIP("QProcess cannot detect failure to start when using posix_spawn()"); +#endif qRegisterMetaType<QProcess::ProcessError>("QProcess::ProcessError"); qRegisterMetaType<QProcess::ExitStatus>("QProcess::ExitStatus"); @@ -1870,6 +1889,9 @@ void tst_QProcess::waitForReadyReadForNonexistantProcess() QVERIFY(!process.waitForReadyRead()); // used to crash process.start("doesntexist"); QVERIFY(!process.waitForReadyRead()); +#ifdef QPROCESS_USE_SPAWN + QEXPECT_FAIL("", "QProcess cannot detect failure to start when using posix_spawn()", Abort); +#endif QCOMPARE(errorSpy.count(), 1); QCOMPARE(errorSpy.at(0).at(0).toInt(), 0); QCOMPARE(finishedSpy1.count(), 0); |