From 1814142b7a11befab315bf3f9d91c4ffbf56ef3e Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 13 Dec 2013 22:07:52 -0800 Subject: 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 --- src/corelib/io/qprocess_p.h | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/corelib/io/qprocess_p.h') diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index 8c5987aa05..3f86960c74 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -62,6 +62,9 @@ typedef HANDLE Q_PIPE; #else typedef int Q_PIPE; #define INVALID_Q_PIPE -1 +# ifdef Q_OS_QNX +# define QPROCESS_USE_SPAWN +# endif #endif #ifndef QT_NO_PROCESS @@ -331,12 +334,13 @@ public: QProcessEnvironment environment; Q_PIPE childStartedPipe[2]; - Q_PIPE deathPipe[2]; void destroyPipe(Q_PIPE pipe[2]); QSocketNotifier *startupSocketNotifier; QSocketNotifier *deathNotifier; + int forkfd; + #ifdef Q_OS_WIN // the wonderful windows notifier QTimer *notifier; @@ -345,10 +349,10 @@ public: void start(QIODevice::OpenMode mode); void startProcess(); -#if defined(Q_OS_UNIX) && !defined(Q_OS_QNX) +#if defined(Q_OS_UNIX) && !defined(QPROCESS_USE_SPAWN) void execChild(const char *workingDirectory, char **path, char **argv, char **envp); -#elif defined(Q_OS_QNX) - pid_t spawnChild(const char *workingDirectory, char **argv, char **envp); +#elif defined(QPROCESS_USE_SPAWN) + pid_t spawnChild(pid_t *ppid, const char *workingDirectory, char **argv, char **envp); #endif bool processStarted(); void terminateProcess(); @@ -369,9 +373,6 @@ public: int exitCode; QProcess::ExitStatus exitStatus; bool crashed; -#ifdef Q_OS_UNIX - int serial; -#endif bool waitForStarted(int msecs = 30000); bool waitForReadyRead(int msecs = 30000); @@ -389,9 +390,6 @@ public: QList defaultNotifiers() const; #endif // Q_OS_BLACKBERRY -#ifdef Q_OS_UNIX - static void initializeProcessManager(); -#endif }; QT_END_NAMESPACE -- cgit v1.2.3