diff options
-rw-r--r-- | src/corelib/io/qprocess.cpp | 15 | ||||
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 7 |
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; } |