summaryrefslogtreecommitdiffstats
path: root/src/corelib/io/qprocess.cpp
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@digia.com>2013-08-27 21:16:22 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-30 21:16:55 +0200
commita1133b215a7a84968113381ab9d49a4a464f1081 (patch)
treece2fd5efc8cfc9c4660f0e54605c22e5441e9240 /src/corelib/io/qprocess.cpp
parent2c916d47ef1338403cf14b4a2684159d865aa4fc (diff)
add QProcess::nullDevice()
Change-Id: I15273fa3f3ba323a835350153f2a20404f12420b Reviewed-by: Lars Knoll <lars.knoll@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/io/qprocess.cpp')
-rw-r--r--src/corelib/io/qprocess.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp
index 96cec568df..d473281acc 100644
--- a/src/corelib/io/qprocess.cpp
+++ b/src/corelib/io/qprocess.cpp
@@ -1317,6 +1317,10 @@ void QProcess::closeWriteChannel()
object will be in read-only mode (calling write() will result in
error).
+ To make the process read EOF right away, pass nullDevice() here.
+ This is cleaner than using closeWriteChannel() before writing any
+ data, because it can be set up prior to starting the process.
+
If the file \a fileName does not exist at the moment start() is
called or is not readable, starting the process will fail.
@@ -1340,6 +1344,10 @@ void QProcess::setStandardInputFile(const QString &fileName)
read channel is closed: reading from it using read() will always
fail, as will readAllStandardOutput().
+ To discard all standard output from the process, pass nullDevice()
+ here. This is more efficient than simply never reading the standard
+ output, as no QProcess buffers are filled.
+
If the file \a fileName doesn't exist at the moment start() is
called, it will be created. If it cannot be created, the starting
will fail.
@@ -2440,6 +2448,25 @@ QStringList QProcess::systemEnvironment()
*/
/*!
+ \since 5.2
+
+ \brief The null device of the operating system.
+
+ The returned file path uses native directory separators.
+
+ \sa QProcess::setStandardInputFile(), QProcess::setStandardOutputFile(),
+ QProcess::setStandardErrorFile()
+*/
+QString QProcess::nullDevice()
+{
+#ifdef Q_OS_WIN
+ return QStringLiteral("\\\\.\\NUL");
+#else
+ return QStringLiteral("/dev/null");
+#endif
+}
+
+/*!
\typedef Q_PID
\relates QProcess