summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess_win.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Do not overwrite detailed error message if process fails to launchKai Koehne2015-11-121-1/+1
| | | | | | | | | | | | | On Unix we get a detailed error message when a process fails to start, but later on we overwrite it with a generic "Process fails to start". Fix this by keeping the original error message (if one is available). This fixes a regression introduced in commit 5147f73ac3. Task-number: QTBUG-49286 Change-Id: Idd0f0fed9773d39f2947fc3e532b51e670952caf Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Merge remote-tracking branch 'origin/5.5' into 5.6Liang Qi2015-08-261-2/+4
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: qmake/doc/snippets/code/doc_src_qmake-manual.pro qmake/doc/src/qmake-manual.qdoc src/corelib/io/qstorageinfo_unix.cpp src/corelib/tools/qbytearray.cpp src/widgets/kernel/qwidgetwindow.cpp tests/auto/corelib/io/qprocess/tst_qprocess.cpp tests/auto/corelib/mimetypes/qmimedatabase/tst_qmimedatabase.cpp tests/auto/network/access/qnetworkreply/BLACKLIST Change-Id: I9efcd7e1cce1c394eed425c43aa6fce7d2edf31c
| * fix assertion in QProcess/WinJoerg Bornemann2015-08-171-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | Do not call bytesAvailableInChannel if the source pipe end is invalid. This is the case when redirecting channels on Windows. The assertions in bytesAvailableInChannel were triggered whenever an output process or output file was set and waitForBytesWritten was called. Task-number: QTBUG-45548 Change-Id: I225dfea2c5e27e122f75008a3a06d425554e00fe Reviewed-by: Alex Trotsenko <alex1973tr@gmail.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Core: Consolidate QProcess error reportingKai Koehne2015-06-201-28/+12
| | | | | | | | | | | | | | | | | | Introduce two methods to set set error and errorString, and optionally emit the error() signal. This also fixes two places where errorString hasn't been set previously. Change-Id: Ib7c27ff2daff898745e8e20ff8f11eaae568697f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* | Use "Ex"-versions of WaitForSingle/MultipleObject(s) where possibleOliver Wolff2015-06-161-2/+2
|/ | | | | | | | | | | | | | Not only should using the "Ex"-versions be the rule and not the exception on Windows, but it's only the only way to share as much code as possible between Desktop Windows and WinRT (which is pushed by Microsoft a lot). The current rule of Desktop and WinCE vs WinRT does not make a lot of sense any longer, as WinCE is getting less and less important. By moving these #ifdefs in favor of WinRT, WinCe code might be removed easier in the future. Change-Id: I0ef94fb14fbf8add9c2dfa2a3fb8036d25fb697d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* remove the "wonderful Windows notifier" from QProcessJoerg Bornemann2015-04-131-17/+2
| | | | | | | | | | | | | Remove the 100 ms timer that was used to nudge QProcess to write data to the child's stdin. Instead, react on the canWrite() signal of QWindowsPipeWriter. QProcess::writeData needs to call _q_canWrite via the event loop to start the write operation. The socket notifier code was never in use on Windows. Task-number: QTBUG-45457 Change-Id: I99c956ba5f2169f80068eee206543ceb9788b2e0 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Update copyright headersJani Heikkinen2015-02-111-7/+7
| | | | | | | | | | | | | | | | | | Qt copyrights are now in The Qt Company, so we could update the source code headers accordingly. In the same go we should also fix the links to point to qt.io. Outdated header.LGPL removed (use header.LGPL21 instead) Old header.LGPL3 renamed to header.LGPL3-COMM to match actual licensing combination. New header.LGPL-COMM taken in the use file which were using old header.LGPL3 (src/plugins/platforms/android/extract.cpp) Added new header.LGPL3 containing Commercial + LGPLv3 + GPLv2 license combination Change-Id: I6f49b819a8a20cc4f88b794a8f6726d975e8ffbe Reviewed-by: Matti Paaso <matti.paaso@theqtcompany.com>
* QProcess/Win: fix sporadic crashJoerg Bornemann2015-02-051-0/+1
| | | | | | | | | | | | | QProcessPrivate::_q_processDied() was potentially called twice if there was a slot connected to readyRead() that called processEvents(), because the processFinishedNotifier was still enabled when readyRead() was emitted. This led to a null pointer access in findExitCode. Change-Id: I4b796b81f050dc46bb9469602984accaa6ebfa28 Task-number: QTBUG-33731 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Avoid sleeping 100ms in QProcessPrivate::drainOutputPipes()Oswald Buddenhagen2014-10-151-1/+1
| | | | | | | | | | | | There is no point in waiting 100 milliseconds after each iteration, as all data that we may possibly read will be already in the pipe. We only need to give the notifier thread a chance to inform us, which is best achieved with a yield. Task-number: QTBUG-41282 Change-Id: Id654b688246508494a5549c11900f9ad2957f192 Reviewed-by: Alessandro Portale <alessandro.portale@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>
* Update license headers and add new license filesMatti Paaso2014-09-241-19/+11
| | | | | | | | | - Renamed LICENSE.LGPL to LICENSE.LGPLv21 - Added LICENSE.LGPLv3 - Removed LICENSE.GPL Change-Id: Iec3406e3eb3f133be549092015cefe33d259a3f2 Reviewed-by: Iikka Eklund <iikka.eklund@digia.com>
* Don't try to read from invalid file descriptors in QProcessThiago Macieira2014-06-121-6/+5
| | | | | | | | | strace reveals that we do ioctl(-1, FIONREAD) and get EBADF. The only case where this could happen is inside _q_processDied, which calls the read functions without checking if the pipe is still open. Change-Id: I67637fc4267be73fc03d40c444fdfea89e1ef715 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* QProcessPrivate: merge the functions dealing with stdout and stderrThiago Macieira2014-06-121-32/+11
| | | | | | | Simplifies the code. Change-Id: I4b3a6e725eb245d3531d1d11d959fb3b85862778 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Rename QProcessPrivate::destroyChannel to closeChannelThiago Macieira2014-06-121-5/+5
| | | | | | | | | | | The QProcessPrivate::Channel object contains some structures that may survive the closing of the pipe, so calling this function "destroy" is incorrect. Let it be just the closing. For symmetry, the createChannel() function is renamed to openChannel(). Change-Id: I2899214c6e4c25835390b10ccf3931315a91589e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Move the QProcessPrivate Windows objects into QProcessPrivate::ChannelThiago Macieira2014-06-121-61/+47
| | | | | | | Similar to the previous commit, this simplifies the code. Change-Id: Ia02b9b5174b4bc6fd04ec2534231b7db5fc914fa Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Move the QProcessPrivate channel buffers into QProcessPrivate::ChannelThiago Macieira2014-06-121-4/+4
| | | | | | | Simplifies the code. Change-Id: I70b26af69332f364d856042f114c37a70504d66f Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* expand tabs and related whitespace fixes in *.{cpp,h,qdoc}Oswald Buddenhagen2014-01-131-1/+1
| | | | | | | | the diff -w for this commit is empty. Started-by: Thiago Macieira <thiago.macieira@intel.com> Change-Id: I77bb84e71c63ce75e0709e5b94bee18e3ce6ab9e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcess/Win: allow child processes to change modes of the stdin pipeJoerg Bornemann2013-12-101-28/+42
| | | | | | | | | | | | | | | | | | | | To be able to call SetNamedPipeHandleState on stdin in a child process, we must create a read-end pipe handle with the FILE_WRITE_ATTRIBUTES flag set. This can't be done with CreateNamedPipe but only with CreateFile. Therefore we're creating the handles for the child process always with CreateFile now. Besides, it's conceptually cleaner to have the server handle of the named pipe in the calling process. [ChangeLog][QtCore][Windows] Fix regression from Qt4 in QProcess. It wasn't possible anymore to alter pipe modes of stdin in child processes. Task-number: QTBUG-35357 Change-Id: I85f09753d0c924bdc8a6cef1ea5dbe6b2299c604 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* QProcess/Win: fix crash in drainOutputPipesJoerg Bornemann2013-10-021-2/+2
| | | | | | | | | | | | | stdoutReader->waitForReadyRead() can synchronously trigger the deletion of stdoutreader (via signal readyRead(), _q_canReadStandardOutput(), destroyChannel()). Analoguous for stderrReader. Task-number: QTBUG-33730 Change-Id: I8badac53e92a979c437838b2959b4c0445c8de81 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* add QProcess::InputChannelModeOswald Buddenhagen2013-09-051-1/+9
| | | | | | | | | | | this enables forwarding standard input from the parent process. Change-Id: I7ee72b9842acc96320d4da693b95dd15d9a7b4d4 Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
* add QProcess::Forwarded{Output,Error}ChannelOswald Buddenhagen2013-09-051-2/+4
| | | | | | | Change-Id: Ifc5ed20c38f3228ef25c28681f296d0456b61abe Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* make the pipe setup code less convolutedOswald Buddenhagen2013-09-051-16/+21
| | | | | | | Change-Id: Ied870c892cc3dbbf24a3d9416f685e51a74e5c17 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
* never create a console for command line tools launched from gui appsOswald Buddenhagen2013-09-051-3/+6
| | | | | | | | | | | | | | | commit 219b0d217 fixed forwarding of stdio to a console. unfortunately, it also forced the creation of a console in the first place if there was none, which is not part of the contract. instead, give the child process a window (== console) only we we already have one. this can be done irrespective of our channel mode, which has the nice side effect that an explicit redirection to a console would now also work. Change-Id: Id25cab5da1ac1cc8ce452127ff95bac8d0a0fea8 Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Maurice Kalinowski <maurice.kalinowski@digia.com>
* remove redundant conditionOswald Buddenhagen2013-09-051-3/+2
| | | | | | | ForwardedChannels implies that both stdoutReader and stderrReader are null. Change-Id: I9d5f02d3a1eac62316a6016b90c612d716ecaafc Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* fix endless loop in QProcess/Win drainOutputPipesJoerg Bornemann2013-07-181-2/+4
| | | | | | | | | | | Commit 568f82fba397e06a26b4fd40f074e4432d02d248 was incomplete. If drainOutputPipes detected some readyRead it wouldn't end the loop. Task-number: QTBUG-32354 Change-Id: I4e594f1e148abe9ef36c047a55eee1b22fd5064b Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* fix infinite loop in QProcessPrivate::drainOutputPipesJoerg Bornemann2013-07-051-1/+1
| | | | | | | | | | | | | | | | | | When drainOutputPipes is called, the process is already dead. If readyReadEmitted is false, there was no data in the pipes. As the process is dead, there won't be data in the pipes in future iterations. The situation that triggered the infinite loop was this: process A starts console process B. B starts console process C. C inherits stdout/err of B. B dies. C runs forever and does not close the stdout/err handles. A notices that B died and calls drainOutputPipes. Task-number: QTBUG-29391 Change-Id: I4819901df307be684c6ad70753a5f964a834704a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* QProcess/Win: drain output pipes on process finishJoerg Bornemann2013-05-071-11/+11
| | | | | | | | | | | | If a process dies before all output is read into the internal buffer of QProcess, we might lose data. Therefore we must drain the output pipes like we already do in the synchronous wait functions. Task-number: QTBUG-30843 Change-Id: I8bbc5265275c9ebd33218ba600267ae87d93ed61 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* QThread: fix race when setting the eventDispatcherDavid Faure2013-03-221-1/+1
| | | | | | | Use QAtomicPointer to make this thread-safe. Change-Id: If71f204699fcefabdb59bd26342d777d1cc9e2a7 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QProcess/Win: stop pipe readers before closing the pipe handlesJoerg Bornemann2013-03-141-0/+2
| | | | | | | | The pipe readers should not operate on closed handles. Change-Id: I6514b949e5ab2adf89633463fc599e8d02c43693 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* QProcess/Win: do not treat all negative exit codes as crashJoerg Bornemann2013-03-131-2/+2
| | | | | | | | | | | | Only exit codes that are likely to be in the range of EXCEPTION_* and STATUS_* codes are treated as crash. Task-number: QTBUG-28735 Change-Id: I36ae6dc4be28df0c6b6b7361df2c2d0203ee7919 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QProcessEnvironment: Permit magic cmd variablesDaniel Teske2013-02-081-1/+2
| | | | | | | | | The cmd shell inserts magic variables starting with a = into the environment. Task-number: QTCREATORBUG-8716 Change-Id: I2f140032aea4fb1d77633c6baf90d7b536e2812a Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
* Update copyright year in Digia's license headersSergio Ahumada2013-01-181-1/+1
| | | | | Change-Id: Ic804938fc352291d011800d21e549c10acac66fb Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Fix compilation with (all versions of) MinGWKai Koehne2012-12-111-1/+1
| | | | | | | | | | | | | | | | Commit 320b16110f0f9cef032a64846dc792d40ccd367b changed the arguments of swprintf to be compliant with latest MinGW-w64 headers: The headers now excludes the non-standard swprintf(wchar*t,wchar_t*,...) version for C++11. However, the swprintf(wchar_t*,size_t,wchar_t*,...) version is actually not supported by e.g. stock Mingw-32 from mingw.org. Instead, use _snwprintf(wchar_t*,size_t,wchar_t*,...), which both MSVC, and all MinGW versions should support. Task-number: QTBUG-28520 Change-Id: Icadd11773a25143e46a72c898adfd1c324f9c468 Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
* QProcess: Fix compilation with MinGWKai Koehne2012-12-061-1/+2
| | | | | | | | newer mingw-w64 headers do not support swprintf(wchar_t*,wchar_t*, ..) any more. Change-Id: I2fc1fb51ba8d5237149697f77a91abd6469ebb09 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Trim trailing whitespace.Stephen Kelly2012-10-221-2/+2
| | | | | Change-Id: Iee6bb66831f53399e5937eab5704af835979f5c3 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* QProcess/Win fix forwarding of output channelsJoerg Bornemann2012-09-281-16/+20
| | | | | | | | | | We must not create pipe readers for the forwarded channels as we don't want to read from stdout/stderr into the internal QProcess buffer. Also, we must not pass CREATE_NO_WINDOW to CreateProcess because this will render our stdout/stderr handles useless. Change-Id: Ie6485e86c103d1e9225cf39c04aa54093c1efe0d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Change copyrights from Nokia to DigiaIikka Eklund2012-09-221-24/+24
| | | | | | | | Change copyrights and license headers from Nokia to Digia Change-Id: If1cc974286d29fd01ec6c19dd4719a67f4c3f00e Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Sergio Ahumada <sergio.ahumada@digia.com>
* Revert "Use true and false in preference to TRUE and FALSE"Sergio Ahumada2012-09-071-8/+8
| | | | | | | | | | | Even though I really think the change was the right thing to do, it seems like Windows people don't like this change because of some Windows Data Types specific rules. This reverts parts of the commit 56d5c909af6473be64a1ae487b45bd444a9a8553. Change-Id: I2c67d9b1bab36fc63937ef386aef56d2a4472a04 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Use true and false in preference to TRUE and FALSESergio Ahumada2012-09-051-8/+8
| | | | | | | | The TRUE and FALSE macros are obsolete and should be replaced with true and false (all lower case) respectively. Change-Id: Iee352e8173500683e6319be0abbf5bacf29016e0 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* get rid of "uninitialized member" gcc warningKonstantin Ritt2012-06-071-2/+1
| | | | | Change-Id: I486212829ec9309239645222e7f03f36ae4847f0 Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
* QProcess/Win: pointless Sleep call removedJoerg Bornemann2012-03-061-2/+0
| | | | | | Change-Id: I634c62d3a0f96bc074e815dfd4106b6187f4ba85 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com> Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* fix QProcess for Windows XPJoerg Bornemann2012-02-201-1/+4
| | | | | | | | | | | | CreateNamedPipe supports the flag PIPE_REJECT_REMOTE_CLIENTS since Windows Vista. On earlier Windows versions the system call would fail with ERROR_INVALID_PARAMETER. This does not open a security hole on Windows XP as there can be only one pipe instance. Change-Id: I5a1c7fdf756678009857317c7b563c884afeef2c Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* MinGW: Fix warnings.Friedemann Kleint2012-02-041-2/+2
| | | | | | | | - Special #define to access HB seems no longer necessary (it was causing about mismatching DLL import attributes). Change-Id: I57cc7d57b12a67c1d549b053db81e1f198f87786 Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
* MinGW build fixes for QWindowsPipeReader and friendsJoerg Bornemann2012-01-311-1/+4
| | | | | Change-Id: Ie4d6017c6fb918e7796d1a5e8863e9368e4e1894 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@nokia.com>
* Remove "All rights reserved" line from license headers.Jason McDonald2012-01-301-1/+1
| | | | | | | | | | As in the past, to avoid rewriting various autotests that contain line-number information, an extra blank line has been inserted at the end of the license text to ensure that this commit does not change the total number of lines in the license header. Change-Id: I311e001373776812699d6efc045b5f742890c689 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* QProcess/Win: use asynchronous I/O for reading stdout and stderrJoerg Bornemann2012-01-261-50/+88
| | | | | | | | This saves us from using the 100 ms polling timer to read process output. Task-number: QTBUG-23012 Change-Id: I3f9398d7a4d30826d2d89ac04bd2fd031500ff57 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* QProcess/Win: use named pipes for redirecting standard I/OJoerg Bornemann2012-01-261-21/+51
| | | | | | | | Named pipes allow us to make use of overlapped I/O for redirected stdin, stdout and stderr. Change-Id: I50191b036bce696147139b200ddbc6c31c16112b Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Update contact information in license headers.Jason McDonald2012-01-231-1/+1
| | | | | | | Replace Nokia contact email address with Qt Project website. Change-Id: I431bbbf76d7c27d8b502f87947675c116994c415 Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>
* QProcess/Win: direct forwarding of stdout and stderrJoerg Bornemann2012-01-081-26/+14
| | | | | | | | | | | | | We are now directly passing the standard out/err handles to CreateProcess instead of reading the output and writing it. The downside is, that we cannot automatically forward the process output of GUI applications anymore. This behaviour is intended by the CreateProcess API. Change-Id: Ic6e35c8c338dbea1a9f345567a37d938da1f34a2 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com> Reviewed-by: Joerg Bornemann <joerg.bornemann@nokia.com>
* split qprocess_win.cpp into Windows and WinCE partsJoerg Bornemann2012-01-061-74/+9
| | | | | Change-Id: I7f2cf2c42dd24ca162238e6dc6408ac39dfcd790 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@nokia.com>
* Update copyright year in license headers.Jason McDonald2012-01-051-1/+1
| | | | | Change-Id: I02f2c620296fcd91d4967d58767ea33fc4e1e7dc Reviewed-by: Rohan McGovern <rohan.mcgovern@nokia.com>