summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-01-11 11:54:42 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-01-11 11:54:42 (GMT)
commit42f3142df03bc978a99fb0c41cd23c8b5a99569c (patch)
tree6b025c484c4ab1e6e3bea223b082f3abf5b144ea
parentb344f1933252ba34c73d03958550eb73746963e9 (diff)
parent7f2e9e43234a112e845568a4329a869975f73a21 (diff)
downloadQt-42f3142df03bc978a99fb0c41cd23c8b5a99569c.zip
Qt-42f3142df03bc978a99fb0c41cd23c8b5a99569c.tar.gz
Qt-42f3142df03bc978a99fb0c41cd23c8b5a99569c.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging into master-integration
* 'master' of scm.dev.nokia.troll.no:qt/qt-earth-staging: handle O_NONBLOCK'ed pipes specific error on write() move POSIX-specific debug to qprocess_unix.cpp
-rw-r--r--src/corelib/io/qprocess.cpp15
-rw-r--r--src/corelib/io/qprocess_unix.cpp7
2 files changed, 14 insertions, 8 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 739ac4d..1522f8e 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -963,9 +963,6 @@ bool QProcessPrivate::_q_canWrite()
destroyPipe(stdinChannel.pipe);
processError = QProcess::WriteError;
q->setErrorString(QProcess::tr("Error writing to process"));
-#if defined(QPROCESS_DEBUG) && !defined(Q_OS_WINCE)
- qDebug("QProcessPrivate::canWrite(), failed to write (%s)", strerror(errno));
-#endif
emit q->error(processError);
return false;
}
@@ -974,11 +971,13 @@ bool QProcessPrivate::_q_canWrite()
qDebug("QProcessPrivate::canWrite(), wrote %d bytes to the process input", int(written));
#endif
- writeBuffer.free(written);
- if (!emittedBytesWritten) {
- emittedBytesWritten = true;
- emit q->bytesWritten(written);
- emittedBytesWritten = false;
+ if (written != 0) {
+ writeBuffer.free(written);
+ if (!emittedBytesWritten) {
+ emittedBytesWritten = true;
+ emit q->bytesWritten(written);
+ emittedBytesWritten = false;
+ }
}
if (stdinChannel.notifier && !writeBuffer.isEmpty())
stdinChannel.notifier->setEnabled(true);
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index e52d132..299280e 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -866,7 +866,14 @@ qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen)
#if defined QPROCESS_DEBUG
qDebug("QProcessPrivate::writeToStdin(%p \"%s\", %lld) == %lld",
data, qt_prettyDebug(data, maxlen, 16).constData(), maxlen, written);
+ if (written == -1)
+ qDebug("QProcessPrivate::writeToStdin(), failed to write (%s)", qt_error_string(errno));
#endif
+ // If the O_NONBLOCK flag is set and If some data can be written without blocking
+ // the process, write() will transfer what it can and return the number of bytes written.
+ // Otherwise, it will return -1 and set errno to EAGAIN
+ if (written == -1 && errno == EAGAIN)
+ written = 0;
return written;
}