summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/io/qprocess.cpp12
-rw-r--r--src/corelib/io/qprocess_unix.cpp5
2 files changed, 12 insertions, 5 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index da53014..1522f8e 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -971,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 0d5464e..299280e 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -869,6 +869,11 @@ qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen)
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;
}