summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_p.h
Commit message (Collapse)AuthorAgeFilesLines
* QProcess/Unix: merge some code from startProcess() and startDetached()Thiago Macieira2023-06-211-1/+3
| | | | | | | | | | | | | | | | | | | | | | | ... into a new local class called QChildProcess. This groups all the information that the child process will need between the fork()/vfork() call and the eventual execve(). That currently includes: - the argv array, including resolving the program name to a path - the envp array, possibly a null - the working directory file descriptor - the disabled thread cancellation state We also move the fork() and vfork() calls to inside of this class, eliminating the the nested lambda was passed to vforkfd(). This duplicates the trick of calling a lambda in the child side of vfork() now for the non-file descriptor version too. None of this should have a side effect for the application. You may be able to tell apart only in system-call tracing tools like strace(1) or truss(1). Change-Id: Ib5ce7a497e034ebabb2cfffd176284edfdd71b32 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess/Unix: add failChildProcessModifier()Thiago Macieira2023-06-091-1/+1
| | | | | | | | | | | | | | | QProcess detects other types of failures from inside the modifier as successful starts, because the childStartedPipe gets closed without an error condition getting written. The new method allows a reporting as a proper failure-to-start. Added tests for both cases. [ChangeLog][QtCore][QProcess] Added failChildProcessModifier(). Change-Id: Icfe44ecf285a480fafe4fffd174da2b10306d3c2 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess/Unix: add setUnixProcessParameters()Thiago Macieira2023-05-221-0/+1
| | | | | | | | | | | | | | | This commit adds those three flags that are either frequent enough or difficult to do: close all file descriptors above stderr and reset the signal handlers. Setting SIGPIPE to be ignored isn't critical, but is required when the ResetSignalHandlers flag is used, as this is run after the user child process modifier. [ChangeLog][QtCore][QProcess] Added setUnixProcessParameters() function that can be used to modify certain settings of the child process, without the need to provide a callback using setChildProcessModifier(). Change-Id: Icfe44ecf285a480fafe4fffd174d0d1d63840403 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: protect against stack unwinding in the child process stubThiago Macieira2023-05-151-1/+1
| | | | | | | | | | | | | | | | | | | | | | There are two types of stack unwinding that can happen on Unix systems: C++ exceptions and PThread cancellations (on some systems, like Linux, PThread cancellations can be caught in catch(...) statements). We call a variety of PThread cancellation functions from inside the child stub, like close(). To avoid problems, we disable PThread cancellations completely before fork() or vfork(). The C++ exception case is simpler, because we can be sure of catching them with the catch (...) statement and simply transform them into an error message. This is also testable, which the PThread cancellation isn't. The error message isn't ideal because we're string-frozen. I'll improve it for 6.6. Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d97a475c93ff1 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: use open() + fchdir() to change directoriesThiago Macieira2023-05-151-1/+1
| | | | | | | | | | This means we have more system calls (2 more in the parent), but we can now detect non-existent or inaccessible directories before fork(). Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d1003581bff59 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcess/Unix: use pid_t for the pidThiago Macieira2023-05-151-1/+1
| | | | | | | | | | | | | | | | | | Qt 5 and earlier versions used to share this member with Windows, where we needed to store a pointer. We had the Q_PID public type, which was removed in commit b73d5a0511bed8c3ccc504e74c52a61d4d3749b4 (6.0). That commit made the QProcess::processId() public API use qint64, which is fine. But we don't need to store more bits than the OS actually requires. This further reduces QProcessPrivate's size to 688 bytes on 64-bit Unix, with 5 bytes of tail padding. Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d3fa9345872c0 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcessPrivate: repack and reorganize the membersThiago Macieira2023-05-151-25/+19
| | | | | | | | | | | | | | | | | Reduce the number of #ifdef blocks and use quint8 for the enums that don't need more than 8 bits anyway (none of them do). Plus move the std::function callback to an indirect block, as most users of QProcess won't set them and this type is 4 pointers with libstdc++ and libc++. After this, QProcessPrivate on 64-bit Unix is 688 bytes, of which: - 392 bytes from QIODevicePrivate - 295 bytes of own data - 3x56 bytes per Channel (which have 5 bytes of tail padding each) - 1 byte of tail padding and no middle padding Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d188a0821d060 Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* QProcessPrivate: remove the member variable "crashed"Thiago Macieira2023-05-131-1/+0
| | | | | | | | | | | | | It was only used to later set exitStatus = CrashExit, so simply do it early. Drive-by removal of a magic numeric literal in the middle of the source code. It's still magic, but at least we avoid accidentally making typos. Pick-to: 6.5 Change-Id: Icfe44ecf285a480fafe4fffd174d4176a5d87641 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
* QProcess/Linux: fix file descriptor leak in case of failed child startThiago Macieira2023-03-161-4/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the child failed to start, execChild() would (unnecessarily) store -1 in childStartedPipe[1] after writing the failure message to it and closing that pipe. This had worked for the previous 20 years of QProcess existence, because that was run in the child process. However, with 6.5 commit e1a787a76ed462e4ed49db78a40c6d7e272182d7 (cherry-picked to 6.4) we implemented vfork-like behavior, meaning the child would share memory with the parent and ran before the parent, so startProcess() failed to close it: // parent // close the ends we don't use and make all pipes non-blocking qt_safe_close(childStartedPipe[1]); Also updated the docs to account for the fact that this is a vfork() environment and, moreover, not using the vfork() function from glibc on Linux. [ChangeLog][QtCore][QProcess] Fixed a file descriptor leak in QProcess when running on Linux 5.4 or later, if the executable being run failed to start (for example, the file for the executable didn't exist). Pick-to: 6.4.3 6.4 6.5 Task-number: QTBUG-111243 Change-Id: I7f354474adce419ca6c2fffd17481002e4853cc3 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Use SPDX license identifiersLucie Gérard2022-05-161-39/+3
| | | | | | | | | | | | | Replace the current license disclaimer in files by a SPDX-License-Identifier. Files that have to be modified by hand are modified. License files are organized under LICENSES directory. Task-number: QTBUG-67283 Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1 Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
* QProcess: Distinguish between null and empty QProcessEnvironmentIevgenii Meshcheriakov2021-11-071-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The documentation for QProcessEnvironment's default constructor says: This constructor creates an empty environment. If set on a QProcess, this will cause the current environment variables to be removed. This is not the case however, because setting such an environment for a process is equivalent to not setting an environment at all and the child process is executed with parent's environment. It is still possible starting from Qt 6.2.0 to create an empty environment by adding a variable to a null environment and removing it, but that's cumbersome, and the comparison operator says that it is equal to the null environment but it is obviously behaving in a different way. This change adds an additional constructor to QProcessEnvironment that can be used to construct a null environment, and changes the default constructor to produce an empty environment. The comparison operator is changed to correctly distinguish between such objects. This is a behavior change, but the current behavior is broken and this is unlikely to affect working code. [ChangeLog][QtCore][QProcessEnvironment] An additional constructor was added to explicitly create an object that when set on QProcess would cause it to inherit the environment from parent (this was formerly the behavior of a default-constructed QProcessEnvironment, which will now (as documented) actually give a process an environment with no variables set). A new method inheritsFromParent() was added to test for such objects. Fixes: QTBUG-58053 Change-Id: I15e20c6a5f01ebe2c736d5578c75dba1ee319320 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Q{LocalSocket|Process}/Win: handle write errorsAlex Trotsenko2021-09-181-0/+1
| | | | | | | | | To match the Unix behavior, we should emit errorOccurred() signal and close the channel if the write operation fails. Change-Id: Iac3acb18dbbfe6e7e8afb2555d9adaff1fe98d0f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
* QProcess/Win: avoid double buffering on writeAlex Trotsenko2021-06-181-5/+4
| | | | | | | | | | | | | As QWindowsPipeWriter now maintains a chunk queue, there is no need to use the internal QIODevice buffer and wait for the previous operation to complete. This also allows us to get rid of the stdinWriteTrigger timer; however, as a trade-off, QWindowsPipeWriter now needs to accept data even before a handle is assigned. Change-Id: I17fe0e36a6165fe05100bfab3fe01fc0d880d617 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess: untangle platform-specific detailsAlex Trotsenko2021-06-041-5/+3
| | | | | | | | | - add missing #ifdef in header file; - split some functions (writeData(), _q_canWrite(), cleanup()) into their platform-specific implementations. Change-Id: I4e7c1c377ec8468ed120d38acf2543eef9316c01 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess: refine 'Channel' structureAlex Trotsenko2021-06-031-19/+10
| | | | | | | | | | - exclude unused notifier pointer on Windows; - use default initialization for members; - avoid bit fields in declarations as there are extra padding bytes anyway. Change-Id: I2e03c4c269c885c90c0a6d18b8a935885f4b3feb Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Introduce QProcessPrivate::closeChannels()Alex Trotsenko2021-05-311-0/+1
| | | | | | | Avoid duplicating code for both platforms. Change-Id: Iae00023672b63e8539cf824fa3aaaff2bf9ae0c5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QWindowsPipe{Reader|Writer}: restructure signalsAlex Trotsenko2021-04-151-0/+3
| | | | | | | | | | | | | | | | | | | For QProcess, there is no point in suppressing recursive QWPR::readyRead() emission, as the former manages this logic itself. On top of that, the non-recursive nature of QWPR::readyRead() indirectly disallowed reading from the channels inside QProcess::waitForReadyRead(), if that is called from a slot connected to QProcess::readyRead(). QWPW had two signals, one allowing recursion and one not. This commit allows recursion of QWPR::readyRead() and QWPW::bytesWritten(), and moves recursion suppression to the higher- level classes. This makes the code more uniform and efficient, at the cost of a few duplicated lines. Change-Id: Ib20017fff4d92403d0bf2335f1622de4aa1ddcef Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess/Win: implement async closing of write channelAlex Trotsenko2021-03-111-1/+0
| | | | | | | | | Instead of blocking in QProcessPrivate::closeWriteChannel(), we can handle a pending close in _q_canWrite() slot when there is no more data to write. Change-Id: I2a30789b6099a2ec075292348ebe33a11341bca3 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess/Unix: remove dead functionAlex Trotsenko2021-01-291-1/+2
| | | | | | | | findExitCode() doesn't do anything on Unix. Change-Id: I3efdc1380a39437c4c029073f3b10ccf7a65e580 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Split QProcessPrivate::_q_processDied()Alex Trotsenko2021-01-091-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The completion of the child process can take place asynchronously or in one of the waitFor...() functions. In both cases, we used the same handler (_q_processDied()), which caused several problems: a. technically, waitForReadyRead() should have taken into account the result of the calls to _q_canRead...() slots inside the _q_processDied() function: - the user calls waitForReadyRead(); - forkfd descriptor becomes signaled, while a grandchild process is still alive; - as readyRead() signal has not been emitted, _q_processDied() is called; - the grandchild process writes to stdout pipe; - now data arrives, and _q_processDied() will collect it, but won't report it. b. we had a bug with recursions on Unix: - death notification comes asynchronously; - waitForDeadChild() closes forkfd; - _q_canRead...() emits readyRead(); - a slot connected to readyRead() calls waitForFinished(); - waitForFinished() hangs (forkfd == -1). c. for blocking functions, drainOutputPipes() was called twice on Windows. By introducing a new processFinished() function, we leave the read operations in the _q_processDied() slot, while the process completion code is guaranteed to run only once. Change-Id: I5f9d09bc68a058169de4d9e490b48fc0b35e94cd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess/Unix: consolidate process state tracking socket notifiersAlex Trotsenko2021-01-081-2/+1
| | | | | | | | | | | | | | | | There is no reason to have the startup notifier and the death notifier be active at the same time, as the former will detect death as well. Previously, these notifiers were racing, but _q_processDied() ordered signals by calling _q_startupNotification() manually. Thus, the started()/finished() sequence was always emitted if the child process was killed anywhere. Now this ordering is simply not necessary anymore. This makes it possible to reuse the startup notifier for death notification. Change-Id: I5ebed9b5f28b19fe56c80498977a3b21be9288fd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess: allow merged channels forwarding for detached processesAlex Trotsenko2020-12-311-0/+3
| | | | | | | | [ChangeLog][QtCore][QProcess] Added support for QProcess::MergedChannels mode with startDetached(). Change-Id: I953ad2063322015332269522a297f8e2842e438c Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess: consolidate channel managementAlex Trotsenko2020-12-311-0/+2
| | | | | | | | | | We have the same channel forwarding, redirecting, and merging rules for all platforms. This makes it possible to introduce the openChannels() function, which consolidates the logic and performs high-level general processing of the channels configuration properties. Change-Id: Id3574fc42a56829328369b6a1a6ec9c95fce8eca Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess/Win: do not needlessly duplicate std handles in startProcess()Alex Trotsenko2020-12-301-0/+1
| | | | | | | | | | | The idea was to create descriptors with HANDLE_FLAG_INHERIT. However, this can be assumed to be already the case for std descriptors, and if it isn't, the user messed up, and we shouldn't try to work around it. This is consistent with what we already do in startDetached(). Change-Id: I8135c5e612c361e77a0442541f2d50cfbb5b4601 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcess: remove unused memberAlex Trotsenko2020-12-151-1/+0
| | | | | Change-Id: I448a32b8ba11426c70d49f7f492b73e7799cc257 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess: migrate to QDeadlineTimerAlex Trotsenko2020-12-091-4/+5
| | | | | | | | | Replacing QElapsedTimer with QDeadlineTimer simplifies the code in waiting functions, which also improves readability. Change-Id: I56aedd356b547b6735ed0985dc81be706e292437 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess: simplify the logic around _q_processDied()Alex Trotsenko2020-12-061-2/+2
| | | | | | | | | | | Both on Unix and Windows, _q_processDied() unconditionally releases all resources associated with the terminated child process, resets QProcess to the initial state, and emits finished() signal. Thus, we can omit reporting success, which also eliminates the related checks from callers. Change-Id: I40e32d1a9ccc8d488be6badba934355d734a8abd Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* Replace discouraged Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPEAndreas Buhr2020-11-301-2/+2
| | | | | | | | | | | | | | Q_MOVABLE_TYPE was conceived before C++ had move semantics. Now, with move semantics, its name is misleading. Q_RELOCATABLE_TYPE was introduced as a synonym to Q_MOVABLE_TYPE. Usage of Q_MOVABLE_TYPE is discouraged now. This patch replaces all usages of Q_MOVABLE_TYPE by Q_RELOCATABLE_TYPE in QtBase. As the two are synonymous, this patch should have no impact on users. Pick-to: 6.0 Change-Id: Ie653984363198c1aeb1f70f8e0fa189aae38eb5c Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
* Refactor QMutexLocker to be able to handle recursive mutexesLars Knoll2020-10-171-1/+1
| | | | | | | | Since we're going to split QMutex and QRecursiveMutex into separate classes, make sure QMutexLocker is prepared for that. Change-Id: Id5e9a955d1db7c8ee663dd3811ad6448dad0aeae Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
* Remove typedef Q_PIDFriedemann Kleint2020-10-021-2/+6
| | | | | | | | | | | It is not used in public API any more since 0f8848b7e25e4d8fb9265ff6e0aa31946addd741. Replace by an internal Windows-specific Q_PROCESS_INFORMATION typedef. Change-Id: Ia6dcc83ca667c40ac5d678c00d143c09d650e42a Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcessPrivate: Use member initializationFriedemann Kleint2020-10-021-18/+18
| | | | | | Change-Id: I9fb8120a68daaa41c153010a52f7a3e99087153b Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess/Unix: introduce setChildProcessModifier()Thiago Macieira2020-09-081-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ChangeLog][Source-Incompatible Changes] QProcess::setupChildProcess() was removed. To execute code in a child process, use QProcess::setChildProcessModifier() [ChangeLog][QtCore][QProcess] Added setChildProcessModifier() function with which one can provide code to be run in the Unix child process between fork() and execve(). With this function, it is no longer necessary to derive from QProcess in order to execute actions in the child process. Another reason is that we can tell whether the std::function carries a valid target much more easily than we can tell whether QProcess was overridden. The setupChildProcess() virtual function does not need to be marked final, since no overrider could ever return an inaccessible private class. This also makes sure the error presented to the user is about the return type, not about attempting to override a final. Clang: error: virtual function 'f' has a different return type ('void') than the function it overrides (which has return type 'QProcess::Use_setChildProcessModifier_Instead') GCC: error: conflicting return type specified for 'virtual void MyProcess::setupChildProcess()' note: overridden function is 'virtual QProcess::Use_setChildProcessModifier_Instead QProcess::setupChildProcess()' ICC: error: return type is neither identical to nor covariant with return type "QProcess::Use_setChildProcessModifier_Instead" of overridden virtual function "QProcess::setupChildProcess" MSVC is not relevant since it doesn't compile to Unix. Change-Id: Ia8b65350cd5d49debca9fffd15f801161363aea7 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
* QProcessEnvironment: simplify lockingMarc Mutz2019-07-161-29/+21
| | | | | | | | | | | | | | | | The mutex is only protecting 'nameMap'. Proof: it's only defined on platforms on which there is a 'nameMap'. Also, nothing else is mutable, so no lazy init going on here. So, drop all the mutex protection, except where we access 'nameMap', and draw the mutex as close as possible to the nameMap uses, iow: copy ctor, prepareName() and nameToString(). As a consequence, the old (Ordered)MutexLocker class only needs to be defined on Unix. Change-Id: Ic969313bc48ad7ebf24c5dca7fd48359956b048d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Port from QAtomic::load() to loadRelaxed()Giuseppe D'Angelo2019-06-201-1/+1
| | | | | | | | | | | | | | | Semi-automated, just needed ~20 manual fixes: $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)load\(\)/$1loadRelaxed\(\)/g' -i \{\} + $ find \( -iname \*.cpp -or -iname \*.h \) -exec perl -pe 's/(\.|->)store\(/$1storeRelaxed\(/g' -i \{\} + It can be easily improved (e.g. for store check that there are no commas after the opening parens). The most common offender is QLibrary::load, and some code using std::atomic directly. Change-Id: I07c38a3c8ed32c924ef4999e85c7e45cf48f0f6c Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Merge remote-tracking branch 'origin/5.13' into devLiang Qi2019-05-071-2/+1
|\ | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/kernel/qobject.cpp src/corelib/kernel/qvariant.h src/corelib/tools/qlist.h Done-With: Milian Wolff <milian.wolff@kdab.com> Done-With: Allan Sandfeld Jensen <allan.jensen@qt.io> Change-Id: I6803f7239aa137a51a7467fab7cc7a01302a848d
| * Fix -Wdeprecated-copy warningsAllan Sandfeld Jensen2019-05-011-2/+1
| | | | | | | | | | | | | | | | | | | | Implicit copy constructors or methods are considered deprecated for classes that has one of the two or a destructor. The warning is enabled with -Wextra in gcc 9 Change-Id: Ic9be654f2a142fb186a4d5a7d6b4f7d6f4e611d8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | More nullptr usage in headersKevin Funk2019-03-141-1/+1
|/ | | | | | | | | | | Diff generated by running clang-tidy's modernize-use-nullptr checker on the CMake-based Qt version. Skipping src/3rdparty, examples/, tests/ Change-Id: Ib182074e2e2fd52f63093f73b3e2e4c0cb7af188 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
* Replace Q_NULLPTR with nullptr where possibleKevin Funk2017-09-191-1/+1
| | | | | | | | | | | | | Remaining uses of Q_NULLPTR are in: src/corelib/global/qcompilerdetection.h (definition and documentation of Q_NULLPTR) tests/manual/qcursor/qcursorhighdpi/main.cpp (a test executable compilable both under Qt4 and Qt5) Change-Id: If6b074d91486e9b784138f4514f5c6d072acda9a Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io> Reviewed-by: Lars Knoll <lars.knoll@qt.io> Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
* Merge remote-tracking branch 'origin/5.9' into devLiang Qi2017-06-191-21/+18
|\ | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/plugins/platforms/android/qandroidplatformintegration.h src/plugins/platforms/windows/qwindowscontext.cpp src/plugins/platforms/windows/windows.pri src/tools/uic/cpp/cppwriteinitialization.cpp src/widgets/doc/src/widgets-and-layouts/gallery.qdoc Change-Id: I8d0834c77f350ea7540140c2c7f372814afc2d0f
| * Use QMap in QProcessEnvironment so variables are sortedThomas Sondergaard2017-06-131-19/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The motivation for this change is to make it simple to pass a correctly sorted environment block to Win32 CreateProcess(). It is also nice in other contexts that the environment variables are sorted. The change is made for all platforms. This keeps it simple and the only ill effect is slightly slower lookups. Concerning the environment block passed to Win32 CreateProcess: The environment block that is passed to CreateProcess() must be sorted case-insensitively and without regard to locale. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms682009(v=vs.85).aspx The need for sorting the environment block is also mentioned in the CreateProcess() documentation, but with less details: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682425(v=vs.85).aspx Task-number: QTBUG-61315 Change-Id: Ie1edd443301de79cf5f699d45beab01b7c0f9de3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
| * Rename QProcessEnvironmentPrivate::hash to varsThomas Sondergaard2017-06-131-3/+3
| | | | | | | | | | | | | | | | | | Also use auto for iterators to vars. This is a small refactoring in preparation for changing type of vars to QMap. Task-number: QTBUG-61315 Change-Id: I5731d7916b6f54a0da5be2da378c09a7688bd870 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Support setCreateProcessArgumentsModifier in QProcess:startDetachedJoerg Bornemann2017-04-231-0/+1
| | | | | | | | | | | | | | | | | | Factor out both CreateProcess calls into one function that also calls the modifier callback for the CreateProcessArguments struct. Task-number: QTBUG-57687 Change-Id: I9d2ef4f2d7cd077aa4c3eba926ab4dfb9e570291 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Simplify Unix implementation of QProcess::start{Process|Detached}Joerg Bornemann2017-03-311-1/+1
| | | | | | | | | | | | | | | | Use QStandardPaths::findExecutable instead of duplicated implementations. Change-Id: Ia944f1d343d8c215fc2b6e78dae6b2bfffbba688 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | Add non-static QProcess::startDetachedJoerg Bornemann2017-03-311-2/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | The three static QProcess::startDetached overloads support a limited number of features: program, arguments and working directory. To support more features of QProcess (without adding a plethora of overloads) we add a non-static method startDetached that can be used as follows: QProcess p; p.setProgram("cat"); p.setArguments("meow"); p.setWorkingDirectory("/tmp"); if (!p.startDetached()) qWarning("Cannot start process."); We plan to add support for nativeArguments, processEnvironment, standard{Output|Error}File and maybe more in subsequent commits. [ChangeLog][QtCore][QProcess] Added non-static QProcess::startDetached to support more features for detached processes. Task-number: QTBUG-2058 Task-number: QTBUG-2284 Task-number: QTBUG-37656 Task-number: QTBUG-52405 Task-number: QTBUG-57687 Change-Id: If6fdd57ecb28cd13aa5fff566216a4177f81d339 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
* Merge remote-tracking branch 'origin/5.8' into 5.9Liang Qi2017-03-131-5/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/network/network.pro mkspecs/features/mac/default_post.prf src/corelib/io/qfilesystemengine_win.cpp src/corelib/io/qprocess.cpp src/corelib/io/qprocess.h src/corelib/io/qprocess_p.h src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/corelib/thread/qmutex.cpp src/platformsupport/fontdatabases/windows/windows.pri src/plugins/platforms/eglfs/eglfsdeviceintegration.pro tests/auto/corelib/io/io.pro Change-Id: I8a27e0e141454818bba9c433200a4e84a88d147e
| * Properly use the "process" featureUlf Hermann2017-02-271-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | Replace all QT_NO_PROCESS with QT_CONFIG(process), define it in qconfig-bootstrapped.h, add QT_REQUIRE_CONFIG(process) to the qprocess headers, exclude the sources from compilation when switched off, guard header inclusions in places where compilation without QProcess seems supported, drop some unused includes, and fix some tests that were apparently designed to work with QT_NO_PROCESS but failed to. Change-Id: Ieceea2504dea6fdf43b81c7c6b65c547b01b9714 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
* | Introduce a configure option for QProcessEnvironmentJake Petroules2016-12-161-4/+8
|/ | | | | | | | This decouples QProcess and QProcessEnvironment, since the latter may actually be available on platforms where the former is not. Change-Id: I3dc799ffdf94486b64143ed01a369897fff44a96 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.6' into 5.7Liang Qi2016-05-061-1/+1
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: examples/qtestlib/tutorial5/containers.cpp examples/widgets/tools/tools.pro src/corelib/io/qprocess.cpp src/corelib/io/qprocess_unix.cpp src/corelib/io/qprocess_win.cpp src/network/kernel/qdnslookup_unix.cpp src/plugins/platforms/xcb/qxcbconnection_xi2.cpp src/testlib/qtestcase.cpp tools/configure/configureapp.cpp Change-Id: I838ae7f082535a67a4a53aa13a21ba5580758be8
| * QWindowsPipeWriter: ensure validity of the write bufferAlex Trotsenko2016-04-301-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | QWindowsPipeWriter uses asynchronous API to perform writing. Once a cycle has been started, the write buffer must remain valid until the write operation is completed. To avoid data corruption and possibly undefined behavior, this patch makes QWindowsPipeWriter::write() take a QByteArray, which it keeps alive for the duration of the write cycle. Autotest-by: Thomas Hartmann Task-number: QTBUG-52401 Change-Id: Ia35faee735c4e684267daa1f6bd689512b670cd2 Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
* | Merge remote-tracking branch 'origin/5.6' into 5.7Simon Hausmann2016-03-231-6/+1
|\| | | | | | | Change-Id: I9a10e1f3c9506ec8554d8f59b6300825ac730939