diff options
author | Liang Qi <liang.qi@theqtcompany.com> | 2016-04-05 14:22:45 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@theqtcompany.com> | 2016-04-05 14:22:45 +0200 |
commit | f2856875843efce9a00e90dad05bde358ab82197 (patch) | |
tree | 93346c38504ce04f0bf02dfe4a21299feb1be8ed /src/corelib/io | |
parent | a7b04275082d065f392e7f18c54ea9b41507ae40 (diff) | |
parent | a2970719c26c946fd6fea7d902aad6706a4ca6ea (diff) |
Merge remote-tracking branch 'origin/5.7' into dev
Conflicts:
examples/corelib/ipc/ipc.pro
src/plugins/platforms/xcb/qxcbbackingstore.cpp
tests/auto/corelib/tools/qcommandlineparser/tst_qcommandlineparser.cpp
Change-Id: Ia006e10ff1732fe78f90138c41f05b59b49486cf
Diffstat (limited to 'src/corelib/io')
-rw-r--r-- | src/corelib/io/forkfd_qt.cpp | 6 | ||||
-rw-r--r-- | src/corelib/io/io.pri | 16 | ||||
-rw-r--r-- | src/corelib/io/qnoncontiguousbytedevice.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qprocess.cpp | 11 | ||||
-rw-r--r-- | src/corelib/io/qprocess_p.h | 7 | ||||
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 187 | ||||
-rw-r--r-- | src/corelib/io/qsettings.cpp | 2 | ||||
-rw-r--r-- | src/corelib/io/qstorageinfo_unix.cpp | 4 | ||||
-rw-r--r-- | src/corelib/io/qwindowspipewriter_p.h | 1 |
9 files changed, 17 insertions, 221 deletions
diff --git a/src/corelib/io/forkfd_qt.cpp b/src/corelib/io/forkfd_qt.cpp index 9bb102e18f..141efeb08c 100644 --- a/src/corelib/io/forkfd_qt.cpp +++ b/src/corelib/io/forkfd_qt.cpp @@ -41,11 +41,7 @@ #include <QtCore/qatomic.h> #include "qprocess_p.h" -#ifdef QPROCESS_USE_SPAWN -# define FORKFD_NO_FORKFD -#else -# define FORKFD_NO_SPAWNFD -#endif +#define FORKFD_NO_SPAWNFD #if defined(QT_NO_DEBUG) && !defined(NDEBUG) # define NDEBUG diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 9d7210fb4f..052dc8408b 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -127,18 +127,20 @@ win32 { io/qsettings_winrt.cpp \ io/qstorageinfo_stub.cpp } -} else:unix|integrity { +} else:unix { SOURCES += \ io/qfsfileengine_unix.cpp \ io/qfilesystemengine_unix.cpp \ io/qlockfile_unix.cpp \ io/qprocess_unix.cpp \ - io/qfilesystemiterator_unix.cpp \ - io/forkfd_qt.cpp - HEADERS += \ - ../3rdparty/forkfd/forkfd.h - INCLUDEPATH += ../3rdparty/forkfd + io/qfilesystemiterator_unix.cpp + !integrity { + SOURCES += io/forkfd_qt.cpp + HEADERS += \ + ../3rdparty/forkfd/forkfd.h + INCLUDEPATH += ../3rdparty/forkfd + } !nacl:mac: { SOURCES += io/qsettings_mac.cpp OBJECTIVE_SOURCES += io/qurl_mac.mm @@ -154,7 +156,7 @@ win32 { } else:ios { LIBS += -framework MobileCoreServices } - } else:android:!android-no-sdk { + } else:android { SOURCES += \ io/qstandardpaths_android.cpp \ io/qstorageinfo_unix.cpp diff --git a/src/corelib/io/qnoncontiguousbytedevice.cpp b/src/corelib/io/qnoncontiguousbytedevice.cpp index 872bebe87b..61299b8aa8 100644 --- a/src/corelib/io/qnoncontiguousbytedevice.cpp +++ b/src/corelib/io/qnoncontiguousbytedevice.cpp @@ -85,7 +85,7 @@ QT_BEGIN_NAMESPACE \internal */ /*! - \fn virtual bool QNonContiguousByteDevice::atEnd() + \fn virtual bool QNonContiguousByteDevice::atEnd() const Returns \c true if everything has been read and the read pointer cannot be advanced anymore. @@ -105,7 +105,7 @@ QT_BEGIN_NAMESPACE \internal */ /*! - \fn virtual qint64 QNonContiguousByteDevice::size() + \fn virtual qint64 QNonContiguousByteDevice::size() const Returns the size of the complete device or -1 if unknown. May also return less/more than what can be actually read with readPointer() diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 90a7f67c48..8b794df6df 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -1183,17 +1183,6 @@ bool QProcessPrivate::_q_processDied() if (crashed) { exitStatus = QProcess::CrashExit; setErrorAndEmit(QProcess::Crashed); - } else { -#ifdef QPROCESS_USE_SPAWN - // if we're using posix_spawn, waitForStarted always succeeds. - // POSIX documents that the sub-process launched by posix_spawn will exit with code - // 127 if anything prevents the target program from starting. - // http://pubs.opengroup.org/onlinepubs/009695399/functions/posix_spawn.html - if (exitStatus == QProcess::NormalExit && exitCode == 127) { - setError(QProcess::FailedToStart, - QProcess::tr("Process failed to start (spawned process exited with code 127)")); - } -#endif } bool wasRunning = (processState == QProcess::Running); diff --git a/src/corelib/io/qprocess_p.h b/src/corelib/io/qprocess_p.h index 043a44df81..1f88c3a043 100644 --- a/src/corelib/io/qprocess_p.h +++ b/src/corelib/io/qprocess_p.h @@ -68,9 +68,6 @@ 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 @@ -352,10 +349,8 @@ public: void start(QIODevice::OpenMode mode); void startProcess(); -#if defined(Q_OS_UNIX) && !defined(QPROCESS_USE_SPAWN) +#if defined(Q_OS_UNIX) void execChild(const char *workingDirectory, char **path, 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(QString *errorMessage = Q_NULLPTR); void terminateProcess(); diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index f9d14c8e5a..a5b7692fc9 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -471,14 +471,8 @@ void QProcessPrivate::startProcess() } // Start the process manager, and fork off the child process. -#if defined(QPROCESS_USE_SPAWN) - pid_t childPid; - forkfd = spawnChild(&childPid, workingDirPtr, argv, envp); - Q_ASSUME(forkfd != FFD_CHILD_PROCESS); -#else pid_t childPid; forkfd = ::forkfd(FFD_CLOEXEC, &childPid); -#endif int lastForkErrno = errno; if (forkfd != FFD_CHILD_PROCESS) { // Parent process. @@ -512,12 +506,10 @@ void QProcessPrivate::startProcess() } // Start the child. -#if !defined(QPROCESS_USE_SPAWN) if (forkfd == FFD_CHILD_PROCESS) { execChild(workingDirPtr, path, argv, envp); ::_exit(-1); } -#endif pid = Q_PID(childPid); @@ -556,147 +548,6 @@ void QProcessPrivate::startProcess() } } -#if defined(QPROCESS_USE_SPAWN) -static int doSpawn(pid_t *ppid, const posix_spawn_file_actions_t *file_actions, - char **argv, char **envp, const char *workingDir, bool spawn_detached) -{ - // A multi threaded QNX Process can't fork so we call spawnfd() instead. - posix_spawnattr_t attr; - posix_spawnattr_init(&attr); -# ifdef Q_OS_QNX - posix_spawnattr_setxflags(&attr, POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETPGROUP - | (spawn_detached * POSIX_SPAWN_NOZOMBIE)); -# else - posix_spawnattr_setflags(&attr, POSIX_SPAWN_SETSIGDEF | POSIX_SPAWN_SETPGROUP); -# endif - posix_spawnattr_setpgroup(&attr, 0); - - sigset_t sigdefault; - sigemptyset(&sigdefault); - sigaddset(&sigdefault, SIGPIPE); // reset the signal that we ignored - posix_spawnattr_setsigdefault(&attr, &sigdefault); - - // enter the working directory - const char *oldWorkingDir = 0; - char buff[PATH_MAX + 1]; - - if (workingDir) { -# ifdef Q_OS_QNX - //we need to freeze everyone in order to avoid race conditions with //chdir(). - if (ThreadCtl(_NTO_TCTL_THREADS_HOLD, 0) == -1) - qWarning("ThreadCtl(): cannot hold threads: %s", qPrintable(qt_error_string(errno))); -# endif - - oldWorkingDir = QT_GETCWD(buff, PATH_MAX + 1); - if (QT_CHDIR(workingDir) == -1) - qWarning("ThreadCtl(): failed to chdir to %s", workingDir); - } - - int fd; - if (spawn_detached) { - fd = ::posix_spawn(ppid, argv[0], file_actions, &attr, argv, envp); - if (fd == -1) { - fd = ::posix_spawnp(ppid, argv[0], file_actions, &attr, argv, envp); - } - } else { - // use spawnfd - fd = ::spawnfd(FFD_CLOEXEC | FFD_NONBLOCK, ppid, argv[0], file_actions, &attr, argv, envp); - if (fd == -1) { - fd = ::spawnfd(FFD_CLOEXEC | FFD_NONBLOCK | FFD_SPAWN_SEARCH_PATH, ppid, argv[0], file_actions, - &attr, argv, envp); - } - } - - if (oldWorkingDir) { - if (QT_CHDIR(oldWorkingDir) == -1) - qWarning("ThreadCtl(): failed to chdir to %s", oldWorkingDir); - -# ifdef Q_OS_QNX - if (Q_UNLIKELY(ThreadCtl(_NTO_TCTL_THREADS_CONT, 0) == -1)) - qFatal("ThreadCtl(): cannot resume threads: %s", qPrintable(qt_error_string(errno))); -# endif - } - - posix_spawnattr_destroy(&attr); - return fd; -} - -pid_t QProcessPrivate::spawnChild(pid_t *ppid, const char *workingDir, char **argv, char **envp) -{ - // posix_spawn causes all file descriptors with FD_CLOEXEC to be closed automatically; - // we only need to add the actions for our own pipes - posix_spawn_file_actions_t file_actions; - posix_spawn_file_actions_init(&file_actions); - -# ifdef Q_OS_QNX - static const bool OS_QNX = true; -# else - static const bool OS_QNX = false; -#endif - - int fdmax = -1; - - if (processChannelMode == QProcess::MergedChannels) { - // managed stderr == stdout - posix_spawn_file_actions_adddup2(&file_actions, stdoutChannel.pipe[1], STDERR_FILENO); - - if (OS_QNX) - fdmax = qMax(fdmax, stdoutChannel.pipe[1]); - } else if (processChannelMode != QProcess::ForwardedChannels && processChannelMode != QProcess::ForwardedErrorChannel) { - // managed stderr - posix_spawn_file_actions_adddup2(&file_actions, stderrChannel.pipe[1], STDERR_FILENO); - - if (OS_QNX) - fdmax = qMax(fdmax, stderrChannel.pipe[1]); - else - posix_spawn_file_actions_addclose(&file_actions, stderrChannel.pipe[1]); - - } - - if (processChannelMode != QProcess::ForwardedChannels && processChannelMode != QProcess::ForwardedOutputChannel) { - // managed stdout - posix_spawn_file_actions_adddup2(&file_actions, stdoutChannel.pipe[1], STDOUT_FILENO); - - if (OS_QNX) - fdmax = qMax(fdmax, stdoutChannel.pipe[1]); - else - posix_spawn_file_actions_addclose(&file_actions, stdoutChannel.pipe[1]); - - } - - if (inputChannelMode == QProcess::ManagedInputChannel) { - posix_spawn_file_actions_adddup2(&file_actions, stdinChannel.pipe[0], STDIN_FILENO); - - if (OS_QNX) - fdmax = qMax(fdmax, stdinChannel.pipe[0]); - else - posix_spawn_file_actions_addclose(&file_actions, stdinChannel.pipe[0]); - } - - // Workaround: QNX's spawn implementation will actually dup all FD values - // LESS than fdmax - regardless of the FD_CLOEEXEC flag. So we need to add - // those to the list of files to close, otherwise dup will fail when some - // other thread closes the FD. - for (int i = 3; i <= fdmax; i++) { - if (::fcntl(i, F_GETFD) & FD_CLOEXEC) - posix_spawn_file_actions_addclose(&file_actions, i); - } - - int retval = doSpawn(ppid, &file_actions, argv, envp, workingDir, false); - - if (retval == -1) { - QString error = qt_error_string(errno); - qt_safe_write(childStartedPipe[1], error.data(), error.length() * sizeof(QChar)); - qt_safe_close(childStartedPipe[1]); - childStartedPipe[1] = -1; - } - - posix_spawn_file_actions_destroy(&file_actions); - return retval; -} - -#else - void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv, char **envp) { ::signal(SIGPIPE, SIG_DFL); // reset the signal that we ignored @@ -770,7 +621,6 @@ report_errno: qt_safe_close(childStartedPipe[1]); childStartedPipe[1] = -1; } -#endif bool QProcessPrivate::processStarted(QString *errorMessage) { @@ -851,7 +701,7 @@ qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen) void QProcessPrivate::terminateProcess() { #if defined (QPROCESS_DEBUG) - qDebug("QProcessPrivate::killProcess()"); + qDebug("QProcessPrivate::terminateProcess()"); #endif if (pid) ::kill(pid_t(pid), SIGTERM); @@ -1064,40 +914,6 @@ bool QProcessPrivate::waitForDeadChild() return true; } -#if defined(QPROCESS_USE_SPAWN) -bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid) -{ - QList<QByteArray> enc_args; - enc_args.append(QFile::encodeName(program)); - for (int i = 0; i < arguments.size(); ++i) - enc_args.append(arguments.at(i).toLocal8Bit()); - - const int argc = enc_args.size(); - QScopedArrayPointer<char*> raw_argv(new char*[argc + 1]); - for (int i = 0; i < argc; ++i) - raw_argv[i] = const_cast<char *>(enc_args.at(i).data()); - raw_argv[argc] = 0; - - char **envp = 0; // inherit environment - - // Encode the working directory if it's non-empty, otherwise just pass 0. - const char *workingDirPtr = 0; - QByteArray encodedWorkingDirectory; - if (!workingDirectory.isEmpty()) { - encodedWorkingDirectory = QFile::encodeName(workingDirectory); - workingDirPtr = encodedWorkingDirectory.constData(); - } - - pid_t childPid; - int retval = doSpawn(&childPid, NULL, raw_argv.data(), envp, workingDirPtr, true); - if (pid && retval != -1) - *pid = childPid; - - return retval != -1; -} - -#else - bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid) { QByteArray encodedWorkingDirectory = QFile::encodeName(workingDirectory); @@ -1212,7 +1028,6 @@ bool QProcessPrivate::startDetached(const QString &program, const QStringList &a qt_safe_close(pidPipe[0]); return success; } -#endif QT_END_NAMESPACE diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp index 8783396bf8..8b61bd268d 100644 --- a/src/corelib/io/qsettings.cpp +++ b/src/corelib/io/qsettings.cpp @@ -2373,8 +2373,6 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile, 10.8 (Mountain Lion), only root can. However, 10.9 (Mavericks) changes that rule again but only for the native format (plist files). - \endlist - \endlist \sa QVariant, QSessionManager, {Settings Editor Example}, {Application Example} diff --git a/src/corelib/io/qstorageinfo_unix.cpp b/src/corelib/io/qstorageinfo_unix.cpp index df47fb479f..a826bcbd9b 100644 --- a/src/corelib/io/qstorageinfo_unix.cpp +++ b/src/corelib/io/qstorageinfo_unix.cpp @@ -513,7 +513,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo() valid = true; ready = true; -#if defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD) +#if defined(Q_OS_INTEGRITY) || (defined(Q_OS_BSD4) && !defined(Q_OS_NETBSD)) bytesTotal = statfs_buf.f_blocks * statfs_buf.f_bsize; bytesFree = statfs_buf.f_bfree * statfs_buf.f_bsize; bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_bsize; @@ -523,7 +523,7 @@ void QStorageInfoPrivate::retrieveVolumeInfo() bytesAvailable = statfs_buf.f_bavail * statfs_buf.f_frsize; #endif blockSize = statfs_buf.f_bsize; -#if defined(Q_OS_ANDROID) || defined (Q_OS_BSD4) +#if defined(Q_OS_ANDROID) || defined(Q_OS_BSD4) || defined(Q_OS_INTEGRITY) #if defined(_STATFS_F_FLAGS) readOnly = (statfs_buf.f_flags & ST_RDONLY) != 0; #endif diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h index 945cbd18bf..59f20edae0 100644 --- a/src/corelib/io/qwindowspipewriter_p.h +++ b/src/corelib/io/qwindowspipewriter_p.h @@ -115,6 +115,7 @@ public: qint64 write(const char *data, qint64 maxlen); void stop(); bool waitForWrite(int msecs); + bool isWriteOperationActive() const { return writeSequenceStarted; } qint64 bytesToWrite() const; Q_SIGNALS: |