diff options
author | Ritt Konstantin <ritt.ks@gmail.com> | 2011-01-11 11:31:44 +0100 |
---|---|---|
committer | Olivier Goffart <olivier.goffart@nokia.com> | 2011-01-11 11:31:44 +0100 |
commit | 7f2e9e43234a112e845568a4329a869975f73a21 (patch) | |
tree | 66f140dfec72b06a9189ef88b2dbbee776e85e21 /src/corelib/io/qprocess_unix.cpp | |
parent | 222fb565e28d5ba7f402755762c6a5df6ffcdd37 (diff) |
handle O_NONBLOCK'ed pipes specific error on write()
according to the write(2) docs:
When write requests greater than {PIPE_BUF} bytes to a pipe that
has available space at least 1 byte, if O_NONBLOCK is set,
write transfers what it can and returns the number of bytes written.
When write requests of {PIPE_BUF} or less bytes to a pipe that has no
enough space, or write requests for greater than {PIPE_BUF} bytes
to a pipe that has no space, if O_NONBLOCK is set,
write returns -1 and sets errno to EAGAIN.
Merge-request: 997
Reviewed-by: Olivier Goffart <olivier.goffart@nokia.com>
Diffstat (limited to 'src/corelib/io/qprocess_unix.cpp')
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 0d5464ea7c..299280e109 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; } |