| Line | Source Code | Coverage |
|---|
| 1 | /**************************************************************************** | - |
| 2 | ** | - |
| 3 | ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). | - |
| 4 | ** Contact: http://www.qt-project.org/legal | - |
| 5 | ** | - |
| 6 | ** This file is part of the QtCore module of the Qt Toolkit. | - |
| 7 | ** | - |
| 8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
| 9 | ** Commercial License Usage | - |
| 10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
| 11 | ** accordance with the commercial license agreement provided with the | - |
| 12 | ** Software or, alternatively, in accordance with the terms contained in | - |
| 13 | ** a written agreement between you and Digia. For licensing terms and | - |
| 14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
| 15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
| 16 | ** | - |
| 17 | ** GNU Lesser General Public License Usage | - |
| 18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
| 19 | ** General Public License version 2.1 as published by the Free Software | - |
| 20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
| 21 | ** packaging of this file. Please review the following information to | - |
| 22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
| 23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
| 24 | ** | - |
| 25 | ** In addition, as a special exception, Digia gives you certain additional | - |
| 26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
| 27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
| 28 | ** | - |
| 29 | ** GNU General Public License Usage | - |
| 30 | ** Alternatively, this file may be used under the terms of the GNU | - |
| 31 | ** General Public License version 3.0 as published by the Free Software | - |
| 32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
| 33 | ** packaging of this file. Please review the following information to | - |
| 34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
| 35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
| 36 | ** | - |
| 37 | ** | - |
| 38 | ** $QT_END_LICENSE$ | - |
| 39 | ** | - |
| 40 | ****************************************************************************/ | - |
| 41 | | - |
| 42 | //#define QPROCESS_DEBUG | - |
| 43 | | - |
| 44 | #include <qdebug.h> | - |
| 45 | #include <qdir.h> | - |
| 46 | #if defined QPROCESS_DEBUG | - |
| 47 | #include <qstring.h> | - |
| 48 | #include <ctype.h> | - |
| 49 | #if !defined(Q_OS_WINCE) | - |
| 50 | #include <errno.h> | - |
| 51 | #endif | - |
| 52 | | - |
| 53 | QT_BEGIN_NAMESPACE | - |
| 54 | /* | - |
| 55 | Returns a human readable representation of the first \a len | - |
| 56 | characters in \a data. | - |
| 57 | */ | - |
| 58 | static QByteArray qt_prettyDebug(const char *data, int len, int maxSize) | - |
| 59 | { | - |
| 60 | if (!data) return "(null)"; | - |
| 61 | QByteArray out; | - |
| 62 | for (int i = 0; i < len && i < maxSize; ++i) { | - |
| 63 | char c = data[i]; | - |
| 64 | if (isprint(c)) { | - |
| 65 | out += c; | - |
| 66 | } else switch (c) { | - |
| 67 | case '\n': out += "\\n"; break; | - |
| 68 | case '\r': out += "\\r"; break; | - |
| 69 | case '\t': out += "\\t"; break; | - |
| 70 | default: | - |
| 71 | char buf[5]; | - |
| 72 | qsnprintf(buf, sizeof(buf), "\\%3o", c); | - |
| 73 | buf[4] = '\0'; | - |
| 74 | out += QByteArray(buf); | - |
| 75 | } | - |
| 76 | } | - |
| 77 | | - |
| 78 | if (len < maxSize) | - |
| 79 | out += "..."; | - |
| 80 | | - |
| 81 | return out; | - |
| 82 | } | - |
| 83 | | - |
| 84 | QT_END_NAMESPACE | - |
| 85 | | - |
| 86 | #endif | - |
| 87 | | - |
| 88 | #include "qprocess.h" | - |
| 89 | #include "qprocess_p.h" | - |
| 90 | | - |
| 91 | #include <qbytearray.h> | - |
| 92 | #include <qelapsedtimer.h> | - |
| 93 | #include <qcoreapplication.h> | - |
| 94 | #include <qsocketnotifier.h> | - |
| 95 | #include <qtimer.h> | - |
| 96 | | - |
| 97 | #ifdef Q_OS_WIN | - |
| 98 | #include <qwineventnotifier.h> | - |
| 99 | #endif | - |
| 100 | | - |
| 101 | #ifndef QT_NO_PROCESS | - |
| 102 | | - |
| 103 | QT_BEGIN_NAMESPACE | - |
| 104 | | - |
| 105 | /*! | - |
| 106 | \class QProcessEnvironment | - |
| 107 | \inmodule QtCore | - |
| 108 | | - |
| 109 | \brief The QProcessEnvironment class holds the environment variables that | - |
| 110 | can be passed to a program. | - |
| 111 | | - |
| 112 | \ingroup io | - |
| 113 | \ingroup misc | - |
| 114 | \ingroup shared | - |
| 115 | \mainclass | - |
| 116 | \reentrant | - |
| 117 | \since 4.6 | - |
| 118 | | - |
| 119 | A process's environment is composed of a set of key=value pairs known as | - |
| 120 | environment variables. The QProcessEnvironment class wraps that concept | - |
| 121 | and allows easy manipulation of those variables. It's meant to be used | - |
| 122 | along with QProcess, to set the environment for child processes. It | - |
| 123 | cannot be used to change the current process's environment. | - |
| 124 | | - |
| 125 | The environment of the calling process can be obtained using | - |
| 126 | QProcessEnvironment::systemEnvironment(). | - |
| 127 | | - |
| 128 | On Unix systems, the variable names are case-sensitive. For that reason, | - |
| 129 | this class will not touch the names of the variables. Note as well that | - |
| 130 | Unix environment allows both variable names and contents to contain arbitrary | - |
| 131 | binary data (except for the NUL character), but this is not supported by | - |
| 132 | QProcessEnvironment. This class only supports names and values that are | - |
| 133 | encodable by the current locale settings (see QTextCodec::codecForLocale). | - |
| 134 | | - |
| 135 | On Windows, the variable names are case-insensitive. Therefore, | - |
| 136 | QProcessEnvironment will always uppercase the names and do case-insensitive | - |
| 137 | comparisons. | - |
| 138 | | - |
| 139 | On Windows CE, the concept of environment does not exist. This class will | - |
| 140 | keep the values set for compatibility with other platforms, but the values | - |
| 141 | set will have no effect on the processes being created. | - |
| 142 | | - |
| 143 | \sa QProcess, QProcess::systemEnvironment(), QProcess::setProcessEnvironment() | - |
| 144 | */ | - |
| 145 | | - |
| 146 | QStringList QProcessEnvironmentPrivate::toList() const | - |
| 147 | { | - |
| 148 | QStringList result; executed (the execution status of this line is deduced): QStringList result; | - |
| 149 | result.reserve(hash.size()); executed (the execution status of this line is deduced): result.reserve(hash.size()); | - |
| 150 | Hash::ConstIterator it = hash.constBegin(), executed (the execution status of this line is deduced): Hash::ConstIterator it = hash.constBegin(), | - |
| 151 | end = hash.constEnd(); executed (the execution status of this line is deduced): end = hash.constEnd(); | - |
| 152 | for ( ; it != end; ++it) { evaluated: it != end| yes Evaluation Count:8 | yes Evaluation Count:4 |
| 4-8 |
| 153 | QString data = nameToString(it.key()); executed (the execution status of this line is deduced): QString data = nameToString(it.key()); | - |
| 154 | QString value = valueToString(it.value()); executed (the execution status of this line is deduced): QString value = valueToString(it.value()); | - |
| 155 | data.reserve(data.length() + value.length() + 1); executed (the execution status of this line is deduced): data.reserve(data.length() + value.length() + 1); | - |
| 156 | data.append(QLatin1Char('=')); executed (the execution status of this line is deduced): data.append(QLatin1Char('=')); | - |
| 157 | data.append(value); executed (the execution status of this line is deduced): data.append(value); | - |
| 158 | result << data; executed (the execution status of this line is deduced): result << data; | - |
| 159 | } executed: }Execution Count:8 | 8 |
| 160 | return result; executed: return result;Execution Count:4 | 4 |
| 161 | } | - |
| 162 | | - |
| 163 | QProcessEnvironment QProcessEnvironmentPrivate::fromList(const QStringList &list) | - |
| 164 | { | - |
| 165 | QProcessEnvironment env; executed (the execution status of this line is deduced): QProcessEnvironment env; | - |
| 166 | QStringList::ConstIterator it = list.constBegin(), executed (the execution status of this line is deduced): QStringList::ConstIterator it = list.constBegin(), | - |
| 167 | end = list.constEnd(); executed (the execution status of this line is deduced): end = list.constEnd(); | - |
| 168 | for ( ; it != end; ++it) { evaluated: it != end| yes Evaluation Count:1975 | yes Evaluation Count:87 |
| 87-1975 |
| 169 | int pos = it->indexOf(QLatin1Char('=')); executed (the execution status of this line is deduced): int pos = it->indexOf(QLatin1Char('=')); | - |
| 170 | if (pos < 1) partially evaluated: pos < 1| no Evaluation Count:0 | yes Evaluation Count:1975 |
| 0-1975 |
| 171 | continue; never executed: continue; | 0 |
| 172 | | - |
| 173 | QString value = it->mid(pos + 1); executed (the execution status of this line is deduced): QString value = it->mid(pos + 1); | - |
| 174 | QString name = *it; executed (the execution status of this line is deduced): QString name = *it; | - |
| 175 | name.truncate(pos); executed (the execution status of this line is deduced): name.truncate(pos); | - |
| 176 | env.insert(name, value); executed (the execution status of this line is deduced): env.insert(name, value); | - |
| 177 | } executed: }Execution Count:1975 | 1975 |
| 178 | return env; executed: return env;Execution Count:87 | 87 |
| 179 | } | - |
| 180 | | - |
| 181 | QStringList QProcessEnvironmentPrivate::keys() const | - |
| 182 | { | - |
| 183 | QStringList result; executed (the execution status of this line is deduced): QStringList result; | - |
| 184 | result.reserve(hash.size()); executed (the execution status of this line is deduced): result.reserve(hash.size()); | - |
| 185 | Hash::ConstIterator it = hash.constBegin(), executed (the execution status of this line is deduced): Hash::ConstIterator it = hash.constBegin(), | - |
| 186 | end = hash.constEnd(); executed (the execution status of this line is deduced): end = hash.constEnd(); | - |
| 187 | for ( ; it != end; ++it) evaluated: it != end| yes Evaluation Count:11 | yes Evaluation Count:4 |
| 4-11 |
| 188 | result << nameToString(it.key()); executed: result << nameToString(it.key());Execution Count:11 | 11 |
| 189 | return result; executed: return result;Execution Count:4 | 4 |
| 190 | } | - |
| 191 | | - |
| 192 | void QProcessEnvironmentPrivate::insert(const QProcessEnvironmentPrivate &other) | - |
| 193 | { | - |
| 194 | Hash::ConstIterator it = other.hash.constBegin(), executed (the execution status of this line is deduced): Hash::ConstIterator it = other.hash.constBegin(), | - |
| 195 | end = other.hash.constEnd(); executed (the execution status of this line is deduced): end = other.hash.constEnd(); | - |
| 196 | for ( ; it != end; ++it) evaluated: it != end| yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
| 197 | hash.insert(it.key(), it.value()); executed: hash.insert(it.key(), it.value());Execution Count:3 | 3 |
| 198 | | - |
| 199 | #ifdef Q_OS_UNIX | - |
| 200 | QHash<QString, Key>::ConstIterator nit = other.nameMap.constBegin(), executed (the execution status of this line is deduced): QHash<QString, Key>::ConstIterator nit = other.nameMap.constBegin(), | - |
| 201 | nend = other.nameMap.constEnd(); executed (the execution status of this line is deduced): nend = other.nameMap.constEnd(); | - |
| 202 | for ( ; nit != nend; ++nit) evaluated: nit != nend| yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
| 203 | nameMap.insert(nit.key(), nit.value()); executed: nameMap.insert(nit.key(), nit.value());Execution Count:3 | 3 |
| 204 | #endif | - |
| 205 | } executed: }Execution Count:1 | 1 |
| 206 | | - |
| 207 | /*! | - |
| 208 | Creates a new QProcessEnvironment object. This constructor creates an | - |
| 209 | empty environment. If set on a QProcess, this will cause the current | - |
| 210 | environment variables to be removed. | - |
| 211 | */ | - |
| 212 | QProcessEnvironment::QProcessEnvironment() | - |
| 213 | : d(0) | - |
| 214 | { | - |
| 215 | } executed: }Execution Count:1834 | 1834 |
| 216 | | - |
| 217 | /*! | - |
| 218 | Frees the resources associated with this QProcessEnvironment object. | - |
| 219 | */ | - |
| 220 | QProcessEnvironment::~QProcessEnvironment() | - |
| 221 | { | - |
| 222 | } | - |
| 223 | | - |
| 224 | /*! | - |
| 225 | Creates a QProcessEnvironment object that is a copy of \a other. | - |
| 226 | */ | - |
| 227 | QProcessEnvironment::QProcessEnvironment(const QProcessEnvironment &other) | - |
| 228 | : d(other.d) | - |
| 229 | { | - |
| 230 | } | 0 |
| 231 | | - |
| 232 | /*! | - |
| 233 | Copies the contents of the \a other QProcessEnvironment object into this | - |
| 234 | one. | - |
| 235 | */ | - |
| 236 | QProcessEnvironment &QProcessEnvironment::operator=(const QProcessEnvironment &other) | - |
| 237 | { | - |
| 238 | d = other.d; executed (the execution status of this line is deduced): d = other.d; | - |
| 239 | return *this; executed: return *this;Execution Count:743 | 743 |
| 240 | } | - |
| 241 | | - |
| 242 | /*! | - |
| 243 | \fn void QProcessEnvironment::swap(QProcessEnvironment &other) | - |
| 244 | \since 5.0 | - |
| 245 | | - |
| 246 | Swaps this process environment instance with \a other. This | - |
| 247 | function is very fast and never fails. | - |
| 248 | */ | - |
| 249 | | - |
| 250 | /*! | - |
| 251 | \fn bool QProcessEnvironment::operator !=(const QProcessEnvironment &other) const | - |
| 252 | | - |
| 253 | Returns true if this and the \a other QProcessEnvironment objects are different. | - |
| 254 | | - |
| 255 | \sa operator==() | - |
| 256 | */ | - |
| 257 | | - |
| 258 | /*! | - |
| 259 | Returns true if this and the \a other QProcessEnvironment objects are equal. | - |
| 260 | | - |
| 261 | Two QProcessEnvironment objects are considered equal if they have the same | - |
| 262 | set of key=value pairs. The comparison of keys is done case-sensitive on | - |
| 263 | platforms where the environment is case-sensitive. | - |
| 264 | | - |
| 265 | \sa operator!=(), contains() | - |
| 266 | */ | - |
| 267 | bool QProcessEnvironment::operator==(const QProcessEnvironment &other) const | - |
| 268 | { | - |
| 269 | return d == other.d || (d && other.d && d->hash == other.d->hash); executed: return d == other.d || (d && other.d && d->hash == other.d->hash);Execution Count:5 | 5 |
| 270 | } | - |
| 271 | | - |
| 272 | /*! | - |
| 273 | Returns true if this QProcessEnvironment object is empty: that is | - |
| 274 | there are no key=value pairs set. | - |
| 275 | | - |
| 276 | \sa clear(), systemEnvironment(), insert() | - |
| 277 | */ | - |
| 278 | bool QProcessEnvironment::isEmpty() const | - |
| 279 | { | - |
| 280 | return d ? d->hash.isEmpty() : true; executed: return d ? d->hash.isEmpty() : true;Execution Count:6 | 6 |
| 281 | } | - |
| 282 | | - |
| 283 | /*! | - |
| 284 | Removes all key=value pairs from this QProcessEnvironment object, making | - |
| 285 | it empty. | - |
| 286 | | - |
| 287 | \sa isEmpty(), systemEnvironment() | - |
| 288 | */ | - |
| 289 | void QProcessEnvironment::clear() | - |
| 290 | { | - |
| 291 | if (d) partially evaluated: d| yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
| 292 | d->hash.clear(); executed: d->hash.clear();Execution Count:7 | 7 |
| 293 | // Unix: Don't clear d->nameMap, as the environment is likely to be | - |
| 294 | // re-populated with the same keys again. | - |
| 295 | } executed: }Execution Count:7 | 7 |
| 296 | | - |
| 297 | /*! | - |
| 298 | Returns true if the environment variable of name \a name is found in | - |
| 299 | this QProcessEnvironment object. | - |
| 300 | | - |
| 301 | On Windows, variable names are case-insensitive, so the key is converted | - |
| 302 | to uppercase before searching. On other systems, names are case-sensitive | - |
| 303 | so no trasformation is applied. | - |
| 304 | | - |
| 305 | \sa insert(), value() | - |
| 306 | */ | - |
| 307 | bool QProcessEnvironment::contains(const QString &name) const | - |
| 308 | { | - |
| 309 | return d ? d->hash.contains(d->prepareName(name)) : false; executed: return d ? d->hash.contains(d->prepareName(name)) : false;Execution Count:14 | 14 |
| 310 | } | - |
| 311 | | - |
| 312 | /*! | - |
| 313 | Inserts the environment variable of name \a name and contents \a value | - |
| 314 | into this QProcessEnvironment object. If that variable already existed, | - |
| 315 | it is replaced by the new value. | - |
| 316 | | - |
| 317 | On Windows, variable names are case-insensitive, so this function always | - |
| 318 | uppercases the variable name before inserting. On other systems, names | - |
| 319 | are case-sensitive, so no transformation is applied. | - |
| 320 | | - |
| 321 | On most systems, inserting a variable with no contents will have the | - |
| 322 | same effect for applications as if the variable had not been set at all. | - |
| 323 | However, to guarantee that there are no incompatibilities, to remove a | - |
| 324 | variable, please use the remove() function. | - |
| 325 | | - |
| 326 | \sa contains(), remove(), value() | - |
| 327 | */ | - |
| 328 | void QProcessEnvironment::insert(const QString &name, const QString &value) | - |
| 329 | { | - |
| 330 | // d detaches from null | - |
| 331 | d->hash.insert(d->prepareName(name), d->prepareValue(value)); executed (the execution status of this line is deduced): d->hash.insert(d->prepareName(name), d->prepareValue(value)); | - |
| 332 | } executed: }Execution Count:2004 | 2004 |
| 333 | | - |
| 334 | /*! | - |
| 335 | Removes the environment variable identified by \a name from this | - |
| 336 | QProcessEnvironment object. If that variable did not exist before, | - |
| 337 | nothing happens. | - |
| 338 | | - |
| 339 | On Windows, variable names are case-insensitive, so the key is converted | - |
| 340 | to uppercase before searching. On other systems, names are case-sensitive | - |
| 341 | so no trasformation is applied. | - |
| 342 | | - |
| 343 | \sa contains(), insert(), value() | - |
| 344 | */ | - |
| 345 | void QProcessEnvironment::remove(const QString &name) | - |
| 346 | { | - |
| 347 | if (d) partially evaluated: d| yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
| 348 | d->hash.remove(d->prepareName(name)); executed: d->hash.remove(d->prepareName(name));Execution Count:3 | 3 |
| 349 | } executed: }Execution Count:3 | 3 |
| 350 | | - |
| 351 | /*! | - |
| 352 | Searches this QProcessEnvironment object for a variable identified by | - |
| 353 | \a name and returns its value. If the variable is not found in this object, | - |
| 354 | then \a defaultValue is returned instead. | - |
| 355 | | - |
| 356 | On Windows, variable names are case-insensitive, so the key is converted | - |
| 357 | to uppercase before searching. On other systems, names are case-sensitive | - |
| 358 | so no trasformation is applied. | - |
| 359 | | - |
| 360 | \sa contains(), insert(), remove() | - |
| 361 | */ | - |
| 362 | QString QProcessEnvironment::value(const QString &name, const QString &defaultValue) const | - |
| 363 | { | - |
| 364 | if (!d) partially evaluated: !d| no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
| 365 | return defaultValue; never executed: return defaultValue; | 0 |
| 366 | | - |
| 367 | QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(d->prepareName(name)); executed (the execution status of this line is deduced): QProcessEnvironmentPrivate::Hash::ConstIterator it = d->hash.constFind(d->prepareName(name)); | - |
| 368 | if (it == d->hash.constEnd()) evaluated: it == d->hash.constEnd()| yes Evaluation Count:2 | yes Evaluation Count:16 |
| 2-16 |
| 369 | return defaultValue; executed: return defaultValue;Execution Count:2 | 2 |
| 370 | | - |
| 371 | return d->valueToString(it.value()); executed: return d->valueToString(it.value());Execution Count:16 | 16 |
| 372 | } | - |
| 373 | | - |
| 374 | /*! | - |
| 375 | Converts this QProcessEnvironment object into a list of strings, one for | - |
| 376 | each environment variable that is set. The environment variable's name | - |
| 377 | and its value are separated by an equal character ('='). | - |
| 378 | | - |
| 379 | The QStringList contents returned by this function are suitable for use | - |
| 380 | with the QProcess::setEnvironment function. However, it is recommended | - |
| 381 | to use QProcess::setProcessEnvironment instead since that will avoid | - |
| 382 | unnecessary copying of the data. | - |
| 383 | | - |
| 384 | \sa systemEnvironment(), QProcess::systemEnvironment(), QProcess::environment(), | - |
| 385 | QProcess::setEnvironment() | - |
| 386 | */ | - |
| 387 | QStringList QProcessEnvironment::toStringList() const | - |
| 388 | { | - |
| 389 | return d ? d->toList() : QStringList(); executed: return d ? d->toList() : QStringList();Execution Count:6 | 6 |
| 390 | } | - |
| 391 | | - |
| 392 | /*! | - |
| 393 | \since 4.8 | - |
| 394 | | - |
| 395 | Returns a list containing all the variable names in this QProcessEnvironment | - |
| 396 | object. | - |
| 397 | */ | - |
| 398 | QStringList QProcessEnvironment::keys() const | - |
| 399 | { | - |
| 400 | return d ? d->keys() : QStringList(); executed: return d ? d->keys() : QStringList();Execution Count:5 | 5 |
| 401 | } | - |
| 402 | | - |
| 403 | /*! | - |
| 404 | \overload | - |
| 405 | \since 4.8 | - |
| 406 | | - |
| 407 | Inserts the contents of \a e in this QProcessEnvironment object. Variables in | - |
| 408 | this object that also exist in \a e will be overwritten. | - |
| 409 | */ | - |
| 410 | void QProcessEnvironment::insert(const QProcessEnvironment &e) | - |
| 411 | { | - |
| 412 | if (!e.d) partially evaluated: !e.d| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 413 | return; | 0 |
| 414 | | - |
| 415 | // d detaches from null | - |
| 416 | d->insert(*e.d); executed (the execution status of this line is deduced): d->insert(*e.d); | - |
| 417 | } executed: }Execution Count:1 | 1 |
| 418 | | - |
| 419 | void QProcessPrivate::Channel::clear() | - |
| 420 | { | - |
| 421 | switch (type) { | - |
| 422 | case PipeSource: | - |
| 423 | Q_ASSERT(process); executed (the execution status of this line is deduced): qt_noop(); | - |
| 424 | process->stdinChannel.type = Normal; executed (the execution status of this line is deduced): process->stdinChannel.type = Normal; | - |
| 425 | process->stdinChannel.process = 0; executed (the execution status of this line is deduced): process->stdinChannel.process = 0; | - |
| 426 | break; executed: break;Execution Count:2 | 2 |
| 427 | case PipeSink: | - |
| 428 | Q_ASSERT(process); never executed (the execution status of this line is deduced): qt_noop(); | - |
| 429 | process->stdoutChannel.type = Normal; never executed (the execution status of this line is deduced): process->stdoutChannel.type = Normal; | - |
| 430 | process->stdoutChannel.process = 0; never executed (the execution status of this line is deduced): process->stdoutChannel.process = 0; | - |
| 431 | break; | 0 |
| 432 | } | - |
| 433 | | - |
| 434 | type = Normal; executed (the execution status of this line is deduced): type = Normal; | - |
| 435 | file.clear(); executed (the execution status of this line is deduced): file.clear(); | - |
| 436 | process = 0; executed (the execution status of this line is deduced): process = 0; | - |
| 437 | } executed: }Execution Count:13 | 13 |
| 438 | | - |
| 439 | /*! \fn bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid) | - |
| 440 | | - |
| 441 | \internal | - |
| 442 | */ | - |
| 443 | | - |
| 444 | /*! | - |
| 445 | \class QProcess | - |
| 446 | \inmodule QtCore | - |
| 447 | | - |
| 448 | \brief The QProcess class is used to start external programs and | - |
| 449 | to communicate with them. | - |
| 450 | | - |
| 451 | \ingroup io | - |
| 452 | | - |
| 453 | \reentrant | - |
| 454 | | - |
| 455 | \section1 Running a Process | - |
| 456 | | - |
| 457 | To start a process, pass the name and command line arguments of | - |
| 458 | the program you want to run as arguments to start(). Arguments | - |
| 459 | are supplied as individual strings in a QStringList. | - |
| 460 | | - |
| 461 | For example, the following code snippet runs the analog clock | - |
| 462 | example in the Fusion style on X11 platforms by passing strings | - |
| 463 | containing "-style" and "fusion" as two items in the list of | - |
| 464 | arguments: | - |
| 465 | | - |
| 466 | \snippet qprocess/qprocess-simpleexecution.cpp 0 | - |
| 467 | \dots | - |
| 468 | \snippet qprocess/qprocess-simpleexecution.cpp 1 | - |
| 469 | \snippet qprocess/qprocess-simpleexecution.cpp 2 | - |
| 470 | | - |
| 471 | QProcess then enters the \l Starting state, and when the program | - |
| 472 | has started, QProcess enters the \l Running state and emits | - |
| 473 | started(). | - |
| 474 | | - |
| 475 | QProcess allows you to treat a process as a sequential I/O | - |
| 476 | device. You can write to and read from the process just as you | - |
| 477 | would access a network connection using QTcpSocket. You can then | - |
| 478 | write to the process's standard input by calling write(), and | - |
| 479 | read the standard output by calling read(), readLine(), and | - |
| 480 | getChar(). Because it inherits QIODevice, QProcess can also be | - |
| 481 | used as an input source for QXmlReader, or for generating data to | - |
| 482 | be uploaded using QNetworkAccessManager. | - |
| 483 | | - |
| 484 | \note On Windows CE, reading and writing to a process | - |
| 485 | is not supported. | - |
| 486 | | - |
| 487 | When the process exits, QProcess reenters the \l NotRunning state | - |
| 488 | (the initial state), and emits finished(). | - |
| 489 | | - |
| 490 | The finished() signal provides the exit code and exit status of | - |
| 491 | the process as arguments, and you can also call exitCode() to | - |
| 492 | obtain the exit code of the last process that finished, and | - |
| 493 | exitStatus() to obtain its exit status. If an error occurs at | - |
| 494 | any point in time, QProcess will emit the error() signal. You | - |
| 495 | can also call error() to find the type of error that occurred | - |
| 496 | last, and state() to find the current process state. | - |
| 497 | | - |
| 498 | \section1 Communicating via Channels | - |
| 499 | | - |
| 500 | Processes have two predefined output channels: The standard | - |
| 501 | output channel (\c stdout) supplies regular console output, and | - |
| 502 | the standard error channel (\c stderr) usually supplies the | - |
| 503 | errors that are printed by the process. These channels represent | - |
| 504 | two separate streams of data. You can toggle between them by | - |
| 505 | calling setReadChannel(). QProcess emits readyRead() when data is | - |
| 506 | available on the current read channel. It also emits | - |
| 507 | readyReadStandardOutput() when new standard output data is | - |
| 508 | available, and when new standard error data is available, | - |
| 509 | readyReadStandardError() is emitted. Instead of calling read(), | - |
| 510 | readLine(), or getChar(), you can explicitly read all data from | - |
| 511 | either of the two channels by calling readAllStandardOutput() or | - |
| 512 | readAllStandardError(). | - |
| 513 | | - |
| 514 | The terminology for the channels can be misleading. Be aware that | - |
| 515 | the process's output channels correspond to QProcess's | - |
| 516 | \e read channels, whereas the process's input channels correspond | - |
| 517 | to QProcess's \e write channels. This is because what we read | - |
| 518 | using QProcess is the process's output, and what we write becomes | - |
| 519 | the process's input. | - |
| 520 | | - |
| 521 | QProcess can merge the two output channels, so that standard | - |
| 522 | output and standard error data from the running process both use | - |
| 523 | the standard output channel. Call setProcessChannelMode() with | - |
| 524 | MergedChannels before starting the process to activative | - |
| 525 | this feature. You also have the option of forwarding the output of | - |
| 526 | the running process to the calling, main process, by passing | - |
| 527 | ForwardedChannels as the argument. | - |
| 528 | | - |
| 529 | Certain processes need special environment settings in order to | - |
| 530 | operate. You can set environment variables for your process by | - |
| 531 | calling setEnvironment(). To set a working directory, call | - |
| 532 | setWorkingDirectory(). By default, processes are run in the | - |
| 533 | current working directory of the calling process. | - |
| 534 | | - |
| 535 | \note On QNX, setting the working directory may cause all | - |
| 536 | application threads, with the exception of the QProcess caller | - |
| 537 | thread, to temporarily freeze during the spawning process, | - |
| 538 | owing to a limitation in the operating system. | - |
| 539 | | - |
| 540 | \section1 Synchronous Process API | - |
| 541 | | - |
| 542 | QProcess provides a set of functions which allow it to be used | - |
| 543 | without an event loop, by suspending the calling thread until | - |
| 544 | certain signals are emitted: | - |
| 545 | | - |
| 546 | \list | - |
| 547 | \li waitForStarted() blocks until the process has started. | - |
| 548 | | - |
| 549 | \li waitForReadyRead() blocks until new data is | - |
| 550 | available for reading on the current read channel. | - |
| 551 | | - |
| 552 | \li waitForBytesWritten() blocks until one payload of | - |
| 553 | data has been written to the process. | - |
| 554 | | - |
| 555 | \li waitForFinished() blocks until the process has finished. | - |
| 556 | \endlist | - |
| 557 | | - |
| 558 | Calling these functions from the main thread (the thread that | - |
| 559 | calls QApplication::exec()) may cause your user interface to | - |
| 560 | freeze. | - |
| 561 | | - |
| 562 | The following example runs \c gzip to compress the string "Qt | - |
| 563 | rocks!", without an event loop: | - |
| 564 | | - |
| 565 | \snippet process/process.cpp 0 | - |
| 566 | | - |
| 567 | \section1 Notes for Windows Users | - |
| 568 | | - |
| 569 | Some Windows commands (for example, \c dir) are not provided by | - |
| 570 | separate applications, but by the command interpreter itself. | - |
| 571 | If you attempt to use QProcess to execute these commands directly, | - |
| 572 | it won't work. One possible solution is to execute the command | - |
| 573 | interpreter itself (\c{cmd.exe} on some Windows systems), and ask | - |
| 574 | the interpreter to execute the desired command. | - |
| 575 | | - |
| 576 | \sa QBuffer, QFile, QTcpSocket | - |
| 577 | */ | - |
| 578 | | - |
| 579 | /*! | - |
| 580 | \enum QProcess::ProcessChannel | - |
| 581 | | - |
| 582 | This enum describes the process channels used by the running process. | - |
| 583 | Pass one of these values to setReadChannel() to set the | - |
| 584 | current read channel of QProcess. | - |
| 585 | | - |
| 586 | \value StandardOutput The standard output (stdout) of the running | - |
| 587 | process. | - |
| 588 | | - |
| 589 | \value StandardError The standard error (stderr) of the running | - |
| 590 | process. | - |
| 591 | | - |
| 592 | \sa setReadChannel() | - |
| 593 | */ | - |
| 594 | | - |
| 595 | /*! | - |
| 596 | \enum QProcess::ProcessChannelMode | - |
| 597 | | - |
| 598 | This enum describes the process channel modes of QProcess. Pass | - |
| 599 | one of these values to setProcessChannelMode() to set the | - |
| 600 | current read channel mode. | - |
| 601 | | - |
| 602 | \value SeparateChannels QProcess manages the output of the | - |
| 603 | running process, keeping standard output and standard error data | - |
| 604 | in separate internal buffers. You can select the QProcess's | - |
| 605 | current read channel by calling setReadChannel(). This is the | - |
| 606 | default channel mode of QProcess. | - |
| 607 | | - |
| 608 | \value MergedChannels QProcess merges the output of the running | - |
| 609 | process into the standard output channel (\c stdout). The | - |
| 610 | standard error channel (\c stderr) will not receive any data. The | - |
| 611 | standard output and standard error data of the running process | - |
| 612 | are interleaved. | - |
| 613 | | - |
| 614 | \value ForwardedChannels QProcess forwards the output of the | - |
| 615 | running process onto the main process. Anything the child process | - |
| 616 | writes to its standard output and standard error will be written | - |
| 617 | to the standard output and standard error of the main process. | - |
| 618 | | - |
| 619 | \note Windows intentionally suppresses output from GUI-only | - |
| 620 | applications to inherited consoles. | - |
| 621 | This does \e not apply to output redirected to files or pipes. | - |
| 622 | To forward the output of GUI-only applications on the console | - |
| 623 | nonetheless, you must use SeparateChannels and do the forwarding | - |
| 624 | yourself by reading the output and writing it to the appropriate | - |
| 625 | output channels. | - |
| 626 | | - |
| 627 | \sa setProcessChannelMode() | - |
| 628 | */ | - |
| 629 | | - |
| 630 | /*! | - |
| 631 | \enum QProcess::ProcessError | - |
| 632 | | - |
| 633 | This enum describes the different types of errors that are | - |
| 634 | reported by QProcess. | - |
| 635 | | - |
| 636 | \value FailedToStart The process failed to start. Either the | - |
| 637 | invoked program is missing, or you may have insufficient | - |
| 638 | permissions to invoke the program. | - |
| 639 | | - |
| 640 | \value Crashed The process crashed some time after starting | - |
| 641 | successfully. | - |
| 642 | | - |
| 643 | \value Timedout The last waitFor...() function timed out. The | - |
| 644 | state of QProcess is unchanged, and you can try calling | - |
| 645 | waitFor...() again. | - |
| 646 | | - |
| 647 | \value WriteError An error occurred when attempting to write to the | - |
| 648 | process. For example, the process may not be running, or it may | - |
| 649 | have closed its input channel. | - |
| 650 | | - |
| 651 | \value ReadError An error occurred when attempting to read from | - |
| 652 | the process. For example, the process may not be running. | - |
| 653 | | - |
| 654 | \value UnknownError An unknown error occurred. This is the default | - |
| 655 | return value of error(). | - |
| 656 | | - |
| 657 | \sa error() | - |
| 658 | */ | - |
| 659 | | - |
| 660 | /*! | - |
| 661 | \enum QProcess::ProcessState | - |
| 662 | | - |
| 663 | This enum describes the different states of QProcess. | - |
| 664 | | - |
| 665 | \value NotRunning The process is not running. | - |
| 666 | | - |
| 667 | \value Starting The process is starting, but the program has not | - |
| 668 | yet been invoked. | - |
| 669 | | - |
| 670 | \value Running The process is running and is ready for reading and | - |
| 671 | writing. | - |
| 672 | | - |
| 673 | \sa state() | - |
| 674 | */ | - |
| 675 | | - |
| 676 | /*! | - |
| 677 | \enum QProcess::ExitStatus | - |
| 678 | | - |
| 679 | This enum describes the different exit statuses of QProcess. | - |
| 680 | | - |
| 681 | \value NormalExit The process exited normally. | - |
| 682 | | - |
| 683 | \value CrashExit The process crashed. | - |
| 684 | | - |
| 685 | \sa exitStatus() | - |
| 686 | */ | - |
| 687 | | - |
| 688 | /*! | - |
| 689 | \fn void QProcess::error(QProcess::ProcessError error) | - |
| 690 | | - |
| 691 | This signal is emitted when an error occurs with the process. The | - |
| 692 | specified \a error describes the type of error that occurred. | - |
| 693 | */ | - |
| 694 | | - |
| 695 | /*! | - |
| 696 | \fn void QProcess::started() | - |
| 697 | | - |
| 698 | This signal is emitted by QProcess when the process has started, | - |
| 699 | and state() returns \l Running. | - |
| 700 | */ | - |
| 701 | | - |
| 702 | /*! | - |
| 703 | \fn void QProcess::stateChanged(QProcess::ProcessState newState) | - |
| 704 | | - |
| 705 | This signal is emitted whenever the state of QProcess changes. The | - |
| 706 | \a newState argument is the state QProcess changed to. | - |
| 707 | */ | - |
| 708 | | - |
| 709 | /*! | - |
| 710 | \fn void QProcess::finished(int exitCode) | - |
| 711 | \obsolete | - |
| 712 | \overload | - |
| 713 | | - |
| 714 | Use finished(int exitCode, QProcess::ExitStatus status) instead. | - |
| 715 | */ | - |
| 716 | | - |
| 717 | /*! | - |
| 718 | \fn void QProcess::finished(int exitCode, QProcess::ExitStatus exitStatus) | - |
| 719 | | - |
| 720 | This signal is emitted when the process finishes. \a exitCode is the exit | - |
| 721 | code of the process, and \a exitStatus is the exit status. After the | - |
| 722 | process has finished, the buffers in QProcess are still intact. You can | - |
| 723 | still read any data that the process may have written before it finished. | - |
| 724 | | - |
| 725 | \sa exitStatus() | - |
| 726 | */ | - |
| 727 | | - |
| 728 | /*! | - |
| 729 | \fn void QProcess::readyReadStandardOutput() | - |
| 730 | | - |
| 731 | This signal is emitted when the process has made new data | - |
| 732 | available through its standard output channel (\c stdout). It is | - |
| 733 | emitted regardless of the current \l{readChannel()}{read channel}. | - |
| 734 | | - |
| 735 | \sa readAllStandardOutput(), readChannel() | - |
| 736 | */ | - |
| 737 | | - |
| 738 | /*! | - |
| 739 | \fn void QProcess::readyReadStandardError() | - |
| 740 | | - |
| 741 | This signal is emitted when the process has made new data | - |
| 742 | available through its standard error channel (\c stderr). It is | - |
| 743 | emitted regardless of the current \l{readChannel()}{read | - |
| 744 | channel}. | - |
| 745 | | - |
| 746 | \sa readAllStandardError(), readChannel() | - |
| 747 | */ | - |
| 748 | | - |
| 749 | /*! | - |
| 750 | \internal | - |
| 751 | */ | - |
| 752 | QProcessPrivate::QProcessPrivate() | - |
| 753 | { | - |
| 754 | processChannel = QProcess::StandardOutput; executed (the execution status of this line is deduced): processChannel = QProcess::StandardOutput; | - |
| 755 | processChannelMode = QProcess::SeparateChannels; executed (the execution status of this line is deduced): processChannelMode = QProcess::SeparateChannels; | - |
| 756 | processError = QProcess::UnknownError; executed (the execution status of this line is deduced): processError = QProcess::UnknownError; | - |
| 757 | processState = QProcess::NotRunning; executed (the execution status of this line is deduced): processState = QProcess::NotRunning; | - |
| 758 | pid = 0; executed (the execution status of this line is deduced): pid = 0; | - |
| 759 | sequenceNumber = 0; executed (the execution status of this line is deduced): sequenceNumber = 0; | - |
| 760 | exitCode = 0; executed (the execution status of this line is deduced): exitCode = 0; | - |
| 761 | exitStatus = QProcess::NormalExit; executed (the execution status of this line is deduced): exitStatus = QProcess::NormalExit; | - |
| 762 | startupSocketNotifier = 0; executed (the execution status of this line is deduced): startupSocketNotifier = 0; | - |
| 763 | deathNotifier = 0; executed (the execution status of this line is deduced): deathNotifier = 0; | - |
| 764 | childStartedPipe[0] = INVALID_Q_PIPE; executed (the execution status of this line is deduced): childStartedPipe[0] = -1; | - |
| 765 | childStartedPipe[1] = INVALID_Q_PIPE; executed (the execution status of this line is deduced): childStartedPipe[1] = -1; | - |
| 766 | deathPipe[0] = INVALID_Q_PIPE; executed (the execution status of this line is deduced): deathPipe[0] = -1; | - |
| 767 | deathPipe[1] = INVALID_Q_PIPE; executed (the execution status of this line is deduced): deathPipe[1] = -1; | - |
| 768 | exitCode = 0; executed (the execution status of this line is deduced): exitCode = 0; | - |
| 769 | crashed = false; executed (the execution status of this line is deduced): crashed = false; | - |
| 770 | dying = false; executed (the execution status of this line is deduced): dying = false; | - |
| 771 | emittedReadyRead = false; executed (the execution status of this line is deduced): emittedReadyRead = false; | - |
| 772 | emittedBytesWritten = false; executed (the execution status of this line is deduced): emittedBytesWritten = false; | - |
| 773 | #ifdef Q_OS_WIN | - |
| 774 | notifier = 0; | - |
| 775 | stdoutReader = 0; | - |
| 776 | stderrReader = 0; | - |
| 777 | pipeWriter = 0; | - |
| 778 | processFinishedNotifier = 0; | - |
| 779 | #endif // Q_OS_WIN | - |
| 780 | #ifdef Q_OS_UNIX | - |
| 781 | serial = 0; executed (the execution status of this line is deduced): serial = 0; | - |
| 782 | #endif | - |
| 783 | } executed: }Execution Count:1721 | 1721 |
| 784 | | - |
| 785 | /*! | - |
| 786 | \internal | - |
| 787 | */ | - |
| 788 | QProcessPrivate::~QProcessPrivate() | - |
| 789 | { | - |
| 790 | if (stdinChannel.process) evaluated: stdinChannel.process| yes Evaluation Count:2 | yes Evaluation Count:1722 |
| 2-1722 |
| 791 | stdinChannel.process->stdoutChannel.clear(); executed: stdinChannel.process->stdoutChannel.clear();Execution Count:2 | 2 |
| 792 | if (stdoutChannel.process) partially evaluated: stdoutChannel.process| no Evaluation Count:0 | yes Evaluation Count:1724 |
| 0-1724 |
| 793 | stdoutChannel.process->stdinChannel.clear(); never executed: stdoutChannel.process->stdinChannel.clear(); | 0 |
| 794 | } executed: }Execution Count:1724 | 1724 |
| 795 | | - |
| 796 | /*! | - |
| 797 | \internal | - |
| 798 | */ | - |
| 799 | void QProcessPrivate::cleanup() | - |
| 800 | { | - |
| 801 | q_func()->setProcessState(QProcess::NotRunning); executed (the execution status of this line is deduced): q_func()->setProcessState(QProcess::NotRunning); | - |
| 802 | #ifdef Q_OS_WIN | - |
| 803 | if (pid) { | - |
| 804 | CloseHandle(pid->hThread); | - |
| 805 | CloseHandle(pid->hProcess); | - |
| 806 | delete pid; | - |
| 807 | pid = 0; | - |
| 808 | } | - |
| 809 | if (processFinishedNotifier) { | - |
| 810 | processFinishedNotifier->setEnabled(false); | - |
| 811 | qDeleteInEventHandler(processFinishedNotifier); | - |
| 812 | processFinishedNotifier = 0; | - |
| 813 | } | - |
| 814 | | - |
| 815 | #endif | - |
| 816 | pid = 0; executed (the execution status of this line is deduced): pid = 0; | - |
| 817 | sequenceNumber = 0; executed (the execution status of this line is deduced): sequenceNumber = 0; | - |
| 818 | dying = false; executed (the execution status of this line is deduced): dying = false; | - |
| 819 | | - |
| 820 | if (stdoutChannel.notifier) { evaluated: stdoutChannel.notifier| yes Evaluation Count:2433 | yes Evaluation Count:1811 |
| 1811-2433 |
| 821 | stdoutChannel.notifier->setEnabled(false); executed (the execution status of this line is deduced): stdoutChannel.notifier->setEnabled(false); | - |
| 822 | qDeleteInEventHandler(stdoutChannel.notifier); executed (the execution status of this line is deduced): qDeleteInEventHandler(stdoutChannel.notifier); | - |
| 823 | stdoutChannel.notifier = 0; executed (the execution status of this line is deduced): stdoutChannel.notifier = 0; | - |
| 824 | } executed: }Execution Count:2433 | 2433 |
| 825 | if (stderrChannel.notifier) { evaluated: stderrChannel.notifier| yes Evaluation Count:2426 | yes Evaluation Count:1818 |
| 1818-2426 |
| 826 | stderrChannel.notifier->setEnabled(false); executed (the execution status of this line is deduced): stderrChannel.notifier->setEnabled(false); | - |
| 827 | qDeleteInEventHandler(stderrChannel.notifier); executed (the execution status of this line is deduced): qDeleteInEventHandler(stderrChannel.notifier); | - |
| 828 | stderrChannel.notifier = 0; executed (the execution status of this line is deduced): stderrChannel.notifier = 0; | - |
| 829 | } executed: }Execution Count:2426 | 2426 |
| 830 | if (stdinChannel.notifier) { evaluated: stdinChannel.notifier| yes Evaluation Count:2234 | yes Evaluation Count:2010 |
| 2010-2234 |
| 831 | stdinChannel.notifier->setEnabled(false); executed (the execution status of this line is deduced): stdinChannel.notifier->setEnabled(false); | - |
| 832 | qDeleteInEventHandler(stdinChannel.notifier); executed (the execution status of this line is deduced): qDeleteInEventHandler(stdinChannel.notifier); | - |
| 833 | stdinChannel.notifier = 0; executed (the execution status of this line is deduced): stdinChannel.notifier = 0; | - |
| 834 | } executed: }Execution Count:2234 | 2234 |
| 835 | if (startupSocketNotifier) { partially evaluated: startupSocketNotifier| no Evaluation Count:0 | yes Evaluation Count:4244 |
| 0-4244 |
| 836 | startupSocketNotifier->setEnabled(false); never executed (the execution status of this line is deduced): startupSocketNotifier->setEnabled(false); | - |
| 837 | qDeleteInEventHandler(startupSocketNotifier); never executed (the execution status of this line is deduced): qDeleteInEventHandler(startupSocketNotifier); | - |
| 838 | startupSocketNotifier = 0; never executed (the execution status of this line is deduced): startupSocketNotifier = 0; | - |
| 839 | } | 0 |
| 840 | if (deathNotifier) { evaluated: deathNotifier| yes Evaluation Count:2439 | yes Evaluation Count:1805 |
| 1805-2439 |
| 841 | deathNotifier->setEnabled(false); executed (the execution status of this line is deduced): deathNotifier->setEnabled(false); | - |
| 842 | qDeleteInEventHandler(deathNotifier); executed (the execution status of this line is deduced): qDeleteInEventHandler(deathNotifier); | - |
| 843 | deathNotifier = 0; executed (the execution status of this line is deduced): deathNotifier = 0; | - |
| 844 | } executed: }Execution Count:2439 | 2439 |
| 845 | #ifdef Q_OS_WIN | - |
| 846 | if (notifier) { | - |
| 847 | qDeleteInEventHandler(notifier); | - |
| 848 | notifier = 0; | - |
| 849 | } | - |
| 850 | #endif | - |
| 851 | destroyChannel(&stdoutChannel); executed (the execution status of this line is deduced): destroyChannel(&stdoutChannel); | - |
| 852 | destroyChannel(&stderrChannel); executed (the execution status of this line is deduced): destroyChannel(&stderrChannel); | - |
| 853 | destroyChannel(&stdinChannel); executed (the execution status of this line is deduced): destroyChannel(&stdinChannel); | - |
| 854 | destroyPipe(childStartedPipe); executed (the execution status of this line is deduced): destroyPipe(childStartedPipe); | - |
| 855 | destroyPipe(deathPipe); executed (the execution status of this line is deduced): destroyPipe(deathPipe); | - |
| 856 | #ifdef Q_OS_UNIX | - |
| 857 | serial = 0; executed (the execution status of this line is deduced): serial = 0; | - |
| 858 | #endif | - |
| 859 | } executed: }Execution Count:4244 | 4244 |
| 860 | | - |
| 861 | /*! | - |
| 862 | \internal | - |
| 863 | */ | - |
| 864 | bool QProcessPrivate::_q_canReadStandardOutput() | - |
| 865 | { | - |
| 866 | Q_Q(QProcess); executed (the execution status of this line is deduced): QProcess * const q = q_func(); | - |
| 867 | qint64 available = bytesAvailableFromStdout(); executed (the execution status of this line is deduced): qint64 available = bytesAvailableFromStdout(); | - |
| 868 | if (available == 0) { evaluated: available == 0| yes Evaluation Count:3349 | yes Evaluation Count:46306 |
| 3349-46306 |
| 869 | if (stdoutChannel.notifier) evaluated: stdoutChannel.notifier| yes Evaluation Count:3339 | yes Evaluation Count:10 |
| 10-3339 |
| 870 | stdoutChannel.notifier->setEnabled(false); executed: stdoutChannel.notifier->setEnabled(false);Execution Count:3339 | 3339 |
| 871 | destroyChannel(&stdoutChannel); executed (the execution status of this line is deduced): destroyChannel(&stdoutChannel); | - |
| 872 | #if defined QPROCESS_DEBUG | - |
| 873 | qDebug("QProcessPrivate::canReadStandardOutput(), 0 bytes available"); | - |
| 874 | #endif | - |
| 875 | return false; executed: return false;Execution Count:3349 | 3349 |
| 876 | } | - |
| 877 | | - |
| 878 | char *ptr = outputReadBuffer.reserve(available); executed (the execution status of this line is deduced): char *ptr = outputReadBuffer.reserve(available); | - |
| 879 | qint64 readBytes = readFromStdout(ptr, available); executed (the execution status of this line is deduced): qint64 readBytes = readFromStdout(ptr, available); | - |
| 880 | if (readBytes == -1) { partially evaluated: readBytes == -1| no Evaluation Count:0 | yes Evaluation Count:46306 |
| 0-46306 |
| 881 | processError = QProcess::ReadError; never executed (the execution status of this line is deduced): processError = QProcess::ReadError; | - |
| 882 | q->setErrorString(QProcess::tr("Error reading from process")); never executed (the execution status of this line is deduced): q->setErrorString(QProcess::tr("Error reading from process")); | - |
| 883 | emit q->error(processError); never executed (the execution status of this line is deduced): q->error(processError); | - |
| 884 | #if defined QPROCESS_DEBUG | - |
| 885 | qDebug("QProcessPrivate::canReadStandardOutput(), failed to read from the process"); | - |
| 886 | #endif | - |
| 887 | return false; never executed: return false; | 0 |
| 888 | } | - |
| 889 | #if defined QPROCESS_DEBUG | - |
| 890 | qDebug("QProcessPrivate::canReadStandardOutput(), read %d bytes from the process' output", | - |
| 891 | int(readBytes)); | - |
| 892 | #endif | - |
| 893 | | - |
| 894 | if (stdoutChannel.closed) { evaluated: stdoutChannel.closed| yes Evaluation Count:5 | yes Evaluation Count:46301 |
| 5-46301 |
| 895 | outputReadBuffer.chop(readBytes); executed (the execution status of this line is deduced): outputReadBuffer.chop(readBytes); | - |
| 896 | return false; executed: return false;Execution Count:5 | 5 |
| 897 | } | - |
| 898 | | - |
| 899 | outputReadBuffer.chop(available - readBytes); executed (the execution status of this line is deduced): outputReadBuffer.chop(available - readBytes); | - |
| 900 | | - |
| 901 | bool didRead = false; executed (the execution status of this line is deduced): bool didRead = false; | - |
| 902 | if (readBytes == 0) { partially evaluated: readBytes == 0| no Evaluation Count:0 | yes Evaluation Count:46301 |
| 0-46301 |
| 903 | if (stdoutChannel.notifier) never evaluated: stdoutChannel.notifier | 0 |
| 904 | stdoutChannel.notifier->setEnabled(false); never executed: stdoutChannel.notifier->setEnabled(false); | 0 |
| 905 | } else if (processChannel == QProcess::StandardOutput) { never executed: } partially evaluated: processChannel == QProcess::StandardOutput| yes Evaluation Count:46301 | no Evaluation Count:0 |
| 0-46301 |
| 906 | didRead = true; executed (the execution status of this line is deduced): didRead = true; | - |
| 907 | if (!emittedReadyRead) { evaluated: !emittedReadyRead| yes Evaluation Count:46300 | yes Evaluation Count:1 |
| 1-46300 |
| 908 | emittedReadyRead = true; executed (the execution status of this line is deduced): emittedReadyRead = true; | - |
| 909 | emit q->readyRead(); executed (the execution status of this line is deduced): q->readyRead(); | - |
| 910 | emittedReadyRead = false; executed (the execution status of this line is deduced): emittedReadyRead = false; | - |
| 911 | } executed: }Execution Count:46300 | 46300 |
| 912 | } executed: }Execution Count:46301 | 46301 |
| 913 | emit q->readyReadStandardOutput(QProcess::QPrivateSignal()); executed (the execution status of this line is deduced): q->readyReadStandardOutput(QProcess::QPrivateSignal()); | - |
| 914 | return didRead; executed: return didRead;Execution Count:46301 | 46301 |
| 915 | } | - |
| 916 | | - |
| 917 | /*! | - |
| 918 | \internal | - |
| 919 | */ | - |
| 920 | bool QProcessPrivate::_q_canReadStandardError() | - |
| 921 | { | - |
| 922 | Q_Q(QProcess); executed (the execution status of this line is deduced): QProcess * const q = q_func(); | - |
| 923 | qint64 available = bytesAvailableFromStderr(); executed (the execution status of this line is deduced): qint64 available = bytesAvailableFromStderr(); | - |
| 924 | if (available == 0) { evaluated: available == 0| yes Evaluation Count:3371 | yes Evaluation Count:359 |
| 359-3371 |
| 925 | if (stderrChannel.notifier) evaluated: stderrChannel.notifier| yes Evaluation Count:3354 | yes Evaluation Count:17 |
| 17-3354 |
| 926 | stderrChannel.notifier->setEnabled(false); executed: stderrChannel.notifier->setEnabled(false);Execution Count:3354 | 3354 |
| 927 | destroyChannel(&stderrChannel); executed (the execution status of this line is deduced): destroyChannel(&stderrChannel); | - |
| 928 | return false; executed: return false;Execution Count:3371 | 3371 |
| 929 | } | - |
| 930 | | - |
| 931 | char *ptr = errorReadBuffer.reserve(available); executed (the execution status of this line is deduced): char *ptr = errorReadBuffer.reserve(available); | - |
| 932 | qint64 readBytes = readFromStderr(ptr, available); executed (the execution status of this line is deduced): qint64 readBytes = readFromStderr(ptr, available); | - |
| 933 | if (readBytes == -1) { partially evaluated: readBytes == -1| no Evaluation Count:0 | yes Evaluation Count:359 |
| 0-359 |
| 934 | processError = QProcess::ReadError; never executed (the execution status of this line is deduced): processError = QProcess::ReadError; | - |
| 935 | q->setErrorString(QProcess::tr("Error reading from process")); never executed (the execution status of this line is deduced): q->setErrorString(QProcess::tr("Error reading from process")); | - |
| 936 | emit q->error(processError); never executed (the execution status of this line is deduced): q->error(processError); | - |
| 937 | return false; never executed: return false; | 0 |
| 938 | } | - |
| 939 | if (stderrChannel.closed) { evaluated: stderrChannel.closed| yes Evaluation Count:9 | yes Evaluation Count:350 |
| 9-350 |
| 940 | errorReadBuffer.chop(readBytes); executed (the execution status of this line is deduced): errorReadBuffer.chop(readBytes); | - |
| 941 | return false; executed: return false;Execution Count:9 | 9 |
| 942 | } | - |
| 943 | | - |
| 944 | errorReadBuffer.chop(available - readBytes); executed (the execution status of this line is deduced): errorReadBuffer.chop(available - readBytes); | - |
| 945 | | - |
| 946 | bool didRead = false; executed (the execution status of this line is deduced): bool didRead = false; | - |
| 947 | if (readBytes == 0) { partially evaluated: readBytes == 0| no Evaluation Count:0 | yes Evaluation Count:350 |
| 0-350 |
| 948 | if (stderrChannel.notifier) never evaluated: stderrChannel.notifier | 0 |
| 949 | stderrChannel.notifier->setEnabled(false); never executed: stderrChannel.notifier->setEnabled(false); | 0 |
| 950 | } else if (processChannel == QProcess::StandardError) { never executed: } evaluated: processChannel == QProcess::StandardError| yes Evaluation Count:13 | yes Evaluation Count:337 |
| 0-337 |
| 951 | didRead = true; executed (the execution status of this line is deduced): didRead = true; | - |
| 952 | if (!emittedReadyRead) { partially evaluated: !emittedReadyRead| yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
| 953 | emittedReadyRead = true; executed (the execution status of this line is deduced): emittedReadyRead = true; | - |
| 954 | emit q->readyRead(); executed (the execution status of this line is deduced): q->readyRead(); | - |
| 955 | emittedReadyRead = false; executed (the execution status of this line is deduced): emittedReadyRead = false; | - |
| 956 | } executed: }Execution Count:13 | 13 |
| 957 | } executed: }Execution Count:13 | 13 |
| 958 | emit q->readyReadStandardError(QProcess::QPrivateSignal()); executed (the execution status of this line is deduced): q->readyReadStandardError(QProcess::QPrivateSignal()); | - |
| 959 | return didRead; executed: return didRead;Execution Count:350 | 350 |
| 960 | } | - |
| 961 | | - |
| 962 | /*! | - |
| 963 | \internal | - |
| 964 | */ | - |
| 965 | bool QProcessPrivate::_q_canWrite() | - |
| 966 | { | - |
| 967 | Q_Q(QProcess); executed (the execution status of this line is deduced): QProcess * const q = q_func(); | - |
| 968 | if (stdinChannel.notifier) partially evaluated: stdinChannel.notifier| yes Evaluation Count:1175 | no Evaluation Count:0 |
| 0-1175 |
| 969 | stdinChannel.notifier->setEnabled(false); executed: stdinChannel.notifier->setEnabled(false);Execution Count:1175 | 1175 |
| 970 | | - |
| 971 | if (writeBuffer.isEmpty()) { partially evaluated: writeBuffer.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:1175 |
| 0-1175 |
| 972 | #if defined QPROCESS_DEBUG | - |
| 973 | qDebug("QProcessPrivate::canWrite(), not writing anything (empty write buffer)."); | - |
| 974 | #endif | - |
| 975 | return false; never executed: return false; | 0 |
| 976 | } | - |
| 977 | | - |
| 978 | qint64 written = writeToStdin(writeBuffer.readPointer(), executed (the execution status of this line is deduced): qint64 written = writeToStdin(writeBuffer.readPointer(), | - |
| 979 | writeBuffer.nextDataBlockSize()); executed (the execution status of this line is deduced): writeBuffer.nextDataBlockSize()); | - |
| 980 | if (written < 0) { partially evaluated: written < 0| no Evaluation Count:0 | yes Evaluation Count:1175 |
| 0-1175 |
| 981 | destroyChannel(&stdinChannel); never executed (the execution status of this line is deduced): destroyChannel(&stdinChannel); | - |
| 982 | processError = QProcess::WriteError; never executed (the execution status of this line is deduced): processError = QProcess::WriteError; | - |
| 983 | q->setErrorString(QProcess::tr("Error writing to process")); never executed (the execution status of this line is deduced): q->setErrorString(QProcess::tr("Error writing to process")); | - |
| 984 | emit q->error(processError); never executed (the execution status of this line is deduced): q->error(processError); | - |
| 985 | return false; never executed: return false; | 0 |
| 986 | } | - |
| 987 | | - |
| 988 | #if defined QPROCESS_DEBUG | - |
| 989 | qDebug("QProcessPrivate::canWrite(), wrote %d bytes to the process input", int(written)); | - |
| 990 | #endif | - |
| 991 | | - |
| 992 | if (written != 0) { partially evaluated: written != 0| yes Evaluation Count:1175 | no Evaluation Count:0 |
| 0-1175 |
| 993 | writeBuffer.free(written); executed (the execution status of this line is deduced): writeBuffer.free(written); | - |
| 994 | if (!emittedBytesWritten) { evaluated: !emittedBytesWritten| yes Evaluation Count:1174 | yes Evaluation Count:1 |
| 1-1174 |
| 995 | emittedBytesWritten = true; executed (the execution status of this line is deduced): emittedBytesWritten = true; | - |
| 996 | emit q->bytesWritten(written); executed (the execution status of this line is deduced): q->bytesWritten(written); | - |
| 997 | emittedBytesWritten = false; executed (the execution status of this line is deduced): emittedBytesWritten = false; | - |
| 998 | } executed: }Execution Count:1174 | 1174 |
| 999 | } executed: }Execution Count:1175 | 1175 |
| 1000 | if (stdinChannel.notifier && !writeBuffer.isEmpty()) partially evaluated: stdinChannel.notifier| yes Evaluation Count:1175 | no Evaluation Count:0 |
evaluated: !writeBuffer.isEmpty()| yes Evaluation Count:725 | yes Evaluation Count:450 |
| 0-1175 |
| 1001 | stdinChannel.notifier->setEnabled(true); executed: stdinChannel.notifier->setEnabled(true);Execution Count:725 | 725 |
| 1002 | if (writeBuffer.isEmpty() && stdinChannel.closed) evaluated: writeBuffer.isEmpty()| yes Evaluation Count:450 | yes Evaluation Count:725 |
evaluated: stdinChannel.closed| yes Evaluation Count:114 | yes Evaluation Count:336 |
| 114-725 |
| 1003 | closeWriteChannel(); executed: closeWriteChannel();Execution Count:114 | 114 |
| 1004 | return true; executed: return true;Execution Count:1175 | 1175 |
| 1005 | } | - |
| 1006 | | - |
| 1007 | /*! | - |
| 1008 | \internal | - |
| 1009 | */ | - |
| 1010 | bool QProcessPrivate::_q_processDied() | - |
| 1011 | { | - |
| 1012 | Q_Q(QProcess); executed (the execution status of this line is deduced): QProcess * const q = q_func(); | - |
| 1013 | #if defined QPROCESS_DEBUG | - |
| 1014 | qDebug("QProcessPrivate::_q_processDied()"); | - |
| 1015 | #endif | - |
| 1016 | #ifdef Q_OS_UNIX | - |
| 1017 | if (!waitForDeadChild()) evaluated: !waitForDeadChild()| yes Evaluation Count:404 | yes Evaluation Count:1693 |
| 404-1693 |
| 1018 | return false; executed: return false;Execution Count:404 | 404 |
| 1019 | #endif | - |
| 1020 | #ifdef Q_OS_WIN | - |
| 1021 | if (processFinishedNotifier) | - |
| 1022 | processFinishedNotifier->setEnabled(false); | - |
| 1023 | #endif | - |
| 1024 | | - |
| 1025 | // the process may have died before it got a chance to report that it was | - |
| 1026 | // either running or stopped, so we will call _q_startupNotification() and | - |
| 1027 | // give it a chance to emit started() or error(FailedToStart). | - |
| 1028 | if (processState == QProcess::Starting) { partially evaluated: processState == QProcess::Starting| no Evaluation Count:0 | yes Evaluation Count:1693 |
| 0-1693 |
| 1029 | if (!_q_startupNotification()) never evaluated: !_q_startupNotification() | 0 |
| 1030 | return true; never executed: return true; | 0 |
| 1031 | } | 0 |
| 1032 | | - |
| 1033 | if (dying) { partially evaluated: dying| no Evaluation Count:0 | yes Evaluation Count:1693 |
| 0-1693 |
| 1034 | // at this point we know the process is dead. prevent | - |
| 1035 | // reentering this slot recursively by calling waitForFinished() | - |
| 1036 | // or opening a dialog inside slots connected to the readyRead | - |
| 1037 | // signals emitted below. | - |
| 1038 | return true; never executed: return true; | 0 |
| 1039 | } | - |
| 1040 | dying = true; executed (the execution status of this line is deduced): dying = true; | - |
| 1041 | | - |
| 1042 | // in case there is data in the pipe line and this slot by chance | - |
| 1043 | // got called before the read notifications, call these two slots | - |
| 1044 | // so the data is made available before the process dies. | - |
| 1045 | _q_canReadStandardOutput(); executed (the execution status of this line is deduced): _q_canReadStandardOutput(); | - |
| 1046 | _q_canReadStandardError(); executed (the execution status of this line is deduced): _q_canReadStandardError(); | - |
| 1047 | | - |
| 1048 | findExitCode(); executed (the execution status of this line is deduced): findExitCode(); | - |
| 1049 | | - |
| 1050 | if (crashed) { evaluated: crashed| yes Evaluation Count:219 | yes Evaluation Count:1474 |
| 219-1474 |
| 1051 | exitStatus = QProcess::CrashExit; executed (the execution status of this line is deduced): exitStatus = QProcess::CrashExit; | - |
| 1052 | processError = QProcess::Crashed; executed (the execution status of this line is deduced): processError = QProcess::Crashed; | - |
| 1053 | q->setErrorString(QProcess::tr("Process crashed")); executed (the execution status of this line is deduced): q->setErrorString(QProcess::tr("Process crashed")); | - |
| 1054 | emit q->error(processError); executed (the execution status of this line is deduced): q->error(processError); | - |
| 1055 | } executed: }Execution Count:219 | 219 |
| 1056 | | - |
| 1057 | bool wasRunning = (processState == QProcess::Running); executed (the execution status of this line is deduced): bool wasRunning = (processState == QProcess::Running); | - |
| 1058 | | - |
| 1059 | cleanup(); executed (the execution status of this line is deduced): cleanup(); | - |
| 1060 | | - |
| 1061 | if (wasRunning) { partially evaluated: wasRunning| yes Evaluation Count:1693 | no Evaluation Count:0 |
| 0-1693 |
| 1062 | // we received EOF now: | - |
| 1063 | emit q->readChannelFinished(); executed (the execution status of this line is deduced): q->readChannelFinished(); | - |
| 1064 | // in the future: | - |
| 1065 | //emit q->standardOutputClosed(); | - |
| 1066 | //emit q->standardErrorClosed(); | - |
| 1067 | | - |
| 1068 | emit q->finished(exitCode); executed (the execution status of this line is deduced): q->finished(exitCode); | - |
| 1069 | emit q->finished(exitCode, exitStatus); executed (the execution status of this line is deduced): q->finished(exitCode, exitStatus); | - |
| 1070 | } executed: }Execution Count:1693 | 1693 |
| 1071 | #if defined QPROCESS_DEBUG | - |
| 1072 | qDebug("QProcessPrivate::_q_processDied() process is dead"); | - |
| 1073 | #endif | - |
| 1074 | return true; executed: return true;Execution Count:1693 | 1693 |
| 1075 | } | - |
| 1076 | | - |
| 1077 | /*! | - |
| 1078 | \internal | - |
| 1079 | */ | - |
| 1080 | bool QProcessPrivate::_q_startupNotification() | - |
| 1081 | { | - |
| 1082 | Q_Q(QProcess); executed (the execution status of this line is deduced): QProcess * const q = q_func(); | - |
| 1083 | #if defined QPROCESS_DEBUG | - |
| 1084 | qDebug("QProcessPrivate::startupNotification()"); | - |
| 1085 | #endif | - |
| 1086 | | - |
| 1087 | if (startupSocketNotifier) evaluated: startupSocketNotifier| yes Evaluation Count:2439 | yes Evaluation Count:81 |
| 81-2439 |
| 1088 | startupSocketNotifier->setEnabled(false); executed: startupSocketNotifier->setEnabled(false);Execution Count:2439 | 2439 |
| 1089 | if (processStarted()) { evaluated: processStarted()| yes Evaluation Count:1693 | yes Evaluation Count:827 |
| 827-1693 |
| 1090 | q->setProcessState(QProcess::Running); executed (the execution status of this line is deduced): q->setProcessState(QProcess::Running); | - |
| 1091 | emit q->started(QProcess::QPrivateSignal()); executed (the execution status of this line is deduced): q->started(QProcess::QPrivateSignal()); | - |
| 1092 | return true; executed: return true;Execution Count:1693 | 1693 |
| 1093 | } | - |
| 1094 | | - |
| 1095 | q->setProcessState(QProcess::NotRunning); executed (the execution status of this line is deduced): q->setProcessState(QProcess::NotRunning); | - |
| 1096 | processError = QProcess::FailedToStart; executed (the execution status of this line is deduced): processError = QProcess::FailedToStart; | - |
| 1097 | emit q->error(processError); executed (the execution status of this line is deduced): q->error(processError); | - |
| 1098 | #ifdef Q_OS_UNIX | - |
| 1099 | // make sure the process manager removes this entry | - |
| 1100 | waitForDeadChild(); executed (the execution status of this line is deduced): waitForDeadChild(); | - |
| 1101 | findExitCode(); executed (the execution status of this line is deduced): findExitCode(); | - |
| 1102 | #endif | - |
| 1103 | cleanup(); executed (the execution status of this line is deduced): cleanup(); | - |
| 1104 | return false; executed: return false;Execution Count:827 | 827 |
| 1105 | } | - |
| 1106 | | - |
| 1107 | /*! | - |
| 1108 | \internal | - |
| 1109 | */ | - |
| 1110 | void QProcessPrivate::closeWriteChannel() | - |
| 1111 | { | - |
| 1112 | #if defined QPROCESS_DEBUG | - |
| 1113 | qDebug("QProcessPrivate::closeWriteChannel()"); | - |
| 1114 | #endif | - |
| 1115 | if (stdinChannel.notifier) { partially evaluated: stdinChannel.notifier| yes Evaluation Count:202 | no Evaluation Count:0 |
| 0-202 |
| 1116 | extern void qDeleteInEventHandler(QObject *o); executed (the execution status of this line is deduced): extern void qDeleteInEventHandler(QObject *o); | - |
| 1117 | stdinChannel.notifier->setEnabled(false); executed (the execution status of this line is deduced): stdinChannel.notifier->setEnabled(false); | - |
| 1118 | if (stdinChannel.notifier) { partially evaluated: stdinChannel.notifier| yes Evaluation Count:202 | no Evaluation Count:0 |
| 0-202 |
| 1119 | qDeleteInEventHandler(stdinChannel.notifier); executed (the execution status of this line is deduced): qDeleteInEventHandler(stdinChannel.notifier); | - |
| 1120 | stdinChannel.notifier = 0; executed (the execution status of this line is deduced): stdinChannel.notifier = 0; | - |
| 1121 | } executed: }Execution Count:202 | 202 |
| 1122 | } executed: }Execution Count:202 | 202 |
| 1123 | #ifdef Q_OS_WIN | - |
| 1124 | // ### Find a better fix, feeding the process little by little | - |
| 1125 | // instead. | - |
| 1126 | flushPipeWriter(); | - |
| 1127 | #endif | - |
| 1128 | destroyChannel(&stdinChannel); executed (the execution status of this line is deduced): destroyChannel(&stdinChannel); | - |
| 1129 | } executed: }Execution Count:202 | 202 |
| 1130 | | - |
| 1131 | /*! | - |
| 1132 | Constructs a QProcess object with the given \a parent. | - |
| 1133 | */ | - |
| 1134 | QProcess::QProcess(QObject *parent) | - |
| 1135 | : QIODevice(*new QProcessPrivate, parent) | - |
| 1136 | { | - |
| 1137 | #if defined QPROCESS_DEBUG | - |
| 1138 | qDebug("QProcess::QProcess(%p)", parent); | - |
| 1139 | #endif | - |
| 1140 | } executed: }Execution Count:1721 | 1721 |
| 1141 | | - |
| 1142 | /*! | - |
| 1143 | Destructs the QProcess object, i.e., killing the process. | - |
| 1144 | | - |
| 1145 | Note that this function will not return until the process is | - |
| 1146 | terminated. | - |
| 1147 | */ | - |
| 1148 | QProcess::~QProcess() | - |
| 1149 | { | - |
| 1150 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1151 | if (d->processState != NotRunning) { evaluated: d->processState != NotRunning| yes Evaluation Count:1 | yes Evaluation Count:1723 |
| 1-1723 |
| 1152 | qWarning().nospace() executed (the execution status of this line is deduced): QMessageLogger("io/qprocess.cpp", 1152, __PRETTY_FUNCTION__).warning().nospace() | - |
| 1153 | << "QProcess: Destroyed while process (" << QDir::toNativeSeparators(program()) << ") is still running."; executed (the execution status of this line is deduced): << "QProcess: Destroyed while process (" << QDir::toNativeSeparators(program()) << ") is still running."; | - |
| 1154 | kill(); executed (the execution status of this line is deduced): kill(); | - |
| 1155 | waitForFinished(); executed (the execution status of this line is deduced): waitForFinished(); | - |
| 1156 | } executed: }Execution Count:1 | 1 |
| 1157 | #ifdef Q_OS_UNIX | - |
| 1158 | // make sure the process manager removes this entry | - |
| 1159 | d->findExitCode(); executed (the execution status of this line is deduced): d->findExitCode(); | - |
| 1160 | #endif | - |
| 1161 | d->cleanup(); executed (the execution status of this line is deduced): d->cleanup(); | - |
| 1162 | } executed: }Execution Count:1724 | 1724 |
| 1163 | | - |
| 1164 | /*! | - |
| 1165 | \obsolete | - |
| 1166 | Returns the read channel mode of the QProcess. This function is | - |
| 1167 | equivalent to processChannelMode() | - |
| 1168 | | - |
| 1169 | \sa processChannelMode() | - |
| 1170 | */ | - |
| 1171 | QProcess::ProcessChannelMode QProcess::readChannelMode() const | - |
| 1172 | { | - |
| 1173 | return processChannelMode(); executed: return processChannelMode();Execution Count:5 | 5 |
| 1174 | } | - |
| 1175 | | - |
| 1176 | /*! | - |
| 1177 | \obsolete | - |
| 1178 | | - |
| 1179 | Use setProcessChannelMode(\a mode) instead. | - |
| 1180 | | - |
| 1181 | \sa setProcessChannelMode() | - |
| 1182 | */ | - |
| 1183 | void QProcess::setReadChannelMode(ProcessChannelMode mode) | - |
| 1184 | { | - |
| 1185 | setProcessChannelMode(mode); executed (the execution status of this line is deduced): setProcessChannelMode(mode); | - |
| 1186 | } executed: }Execution Count:20 | 20 |
| 1187 | | - |
| 1188 | /*! | - |
| 1189 | \since 4.2 | - |
| 1190 | | - |
| 1191 | Returns the channel mode of the QProcess standard output and | - |
| 1192 | standard error channels. | - |
| 1193 | | - |
| 1194 | \sa setProcessChannelMode(), ProcessChannelMode, setReadChannel() | - |
| 1195 | */ | - |
| 1196 | QProcess::ProcessChannelMode QProcess::processChannelMode() const | - |
| 1197 | { | - |
| 1198 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1199 | return d->processChannelMode; executed: return d->processChannelMode;Execution Count:5 | 5 |
| 1200 | } | - |
| 1201 | | - |
| 1202 | /*! | - |
| 1203 | \since 4.2 | - |
| 1204 | | - |
| 1205 | Sets the channel mode of the QProcess standard output and standard | - |
| 1206 | error channels to the \a mode specified. | - |
| 1207 | This mode will be used the next time start() is called. For example: | - |
| 1208 | | - |
| 1209 | \snippet code/src_corelib_io_qprocess.cpp 0 | - |
| 1210 | | - |
| 1211 | \sa processChannelMode(), ProcessChannelMode, setReadChannel() | - |
| 1212 | */ | - |
| 1213 | void QProcess::setProcessChannelMode(ProcessChannelMode mode) | - |
| 1214 | { | - |
| 1215 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1216 | d->processChannelMode = mode; executed (the execution status of this line is deduced): d->processChannelMode = mode; | - |
| 1217 | } executed: }Execution Count:143 | 143 |
| 1218 | | - |
| 1219 | /*! | - |
| 1220 | Returns the current read channel of the QProcess. | - |
| 1221 | | - |
| 1222 | \sa setReadChannel() | - |
| 1223 | */ | - |
| 1224 | QProcess::ProcessChannel QProcess::readChannel() const | - |
| 1225 | { | - |
| 1226 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1227 | return d->processChannel; executed: return d->processChannel;Execution Count:1233 | 1233 |
| 1228 | } | - |
| 1229 | | - |
| 1230 | /*! | - |
| 1231 | Sets the current read channel of the QProcess to the given \a | - |
| 1232 | channel. The current input channel is used by the functions | - |
| 1233 | read(), readAll(), readLine(), and getChar(). It also determines | - |
| 1234 | which channel triggers QProcess to emit readyRead(). | - |
| 1235 | | - |
| 1236 | \sa readChannel() | - |
| 1237 | */ | - |
| 1238 | void QProcess::setReadChannel(ProcessChannel channel) | - |
| 1239 | { | - |
| 1240 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1241 | if (d->processChannel != channel) { evaluated: d->processChannel != channel| yes Evaluation Count:1490 | yes Evaluation Count:1008 |
| 1008-1490 |
| 1242 | QByteArray buf = d->buffer.readAll(); executed (the execution status of this line is deduced): QByteArray buf = d->buffer.readAll(); | - |
| 1243 | if (d->processChannel == QProcess::StandardOutput) { evaluated: d->processChannel == QProcess::StandardOutput| yes Evaluation Count:750 | yes Evaluation Count:740 |
| 740-750 |
| 1244 | for (int i = buf.size() - 1; i >= 0; --i) evaluated: i >= 0| yes Evaluation Count:7 | yes Evaluation Count:750 |
| 7-750 |
| 1245 | d->outputReadBuffer.ungetChar(buf.at(i)); executed: d->outputReadBuffer.ungetChar(buf.at(i));Execution Count:7 | 7 |
| 1246 | } else { executed: }Execution Count:750 | 750 |
| 1247 | for (int i = buf.size() - 1; i >= 0; --i) evaluated: i >= 0| yes Evaluation Count:7 | yes Evaluation Count:740 |
| 7-740 |
| 1248 | d->errorReadBuffer.ungetChar(buf.at(i)); executed: d->errorReadBuffer.ungetChar(buf.at(i));Execution Count:7 | 7 |
| 1249 | } executed: }Execution Count:740 | 740 |
| 1250 | } | - |
| 1251 | d->processChannel = channel; executed (the execution status of this line is deduced): d->processChannel = channel; | - |
| 1252 | } executed: }Execution Count:2498 | 2498 |
| 1253 | | - |
| 1254 | /*! | - |
| 1255 | Closes the read channel \a channel. After calling this function, | - |
| 1256 | QProcess will no longer receive data on the channel. Any data that | - |
| 1257 | has already been received is still available for reading. | - |
| 1258 | | - |
| 1259 | Call this function to save memory, if you are not interested in | - |
| 1260 | the output of the process. | - |
| 1261 | | - |
| 1262 | \sa closeWriteChannel(), setReadChannel() | - |
| 1263 | */ | - |
| 1264 | void QProcess::closeReadChannel(ProcessChannel channel) | - |
| 1265 | { | - |
| 1266 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1267 | | - |
| 1268 | if (channel == StandardOutput) evaluated: channel == StandardOutput| yes Evaluation Count:6 | yes Evaluation Count:6 |
| 6 |
| 1269 | d->stdoutChannel.closed = true; executed: d->stdoutChannel.closed = true;Execution Count:6 | 6 |
| 1270 | else | - |
| 1271 | d->stderrChannel.closed = true; executed: d->stderrChannel.closed = true;Execution Count:6 | 6 |
| 1272 | } | - |
| 1273 | | - |
| 1274 | /*! | - |
| 1275 | Schedules the write channel of QProcess to be closed. The channel | - |
| 1276 | will close once all data has been written to the process. After | - |
| 1277 | calling this function, any attempts to write to the process will | - |
| 1278 | fail. | - |
| 1279 | | - |
| 1280 | Closing the write channel is necessary for programs that read | - |
| 1281 | input data until the channel has been closed. For example, the | - |
| 1282 | program "more" is used to display text data in a console on both | - |
| 1283 | Unix and Windows. But it will not display the text data until | - |
| 1284 | QProcess's write channel has been closed. Example: | - |
| 1285 | | - |
| 1286 | \snippet code/src_corelib_io_qprocess.cpp 1 | - |
| 1287 | | - |
| 1288 | The write channel is implicitly opened when start() is called. | - |
| 1289 | | - |
| 1290 | \sa closeReadChannel() | - |
| 1291 | */ | - |
| 1292 | void QProcess::closeWriteChannel() | - |
| 1293 | { | - |
| 1294 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1295 | d->stdinChannel.closed = true; // closing executed (the execution status of this line is deduced): d->stdinChannel.closed = true; | - |
| 1296 | if (d->writeBuffer.isEmpty()) evaluated: d->writeBuffer.isEmpty()| yes Evaluation Count:88 | yes Evaluation Count:114 |
| 88-114 |
| 1297 | d->closeWriteChannel(); executed: d->closeWriteChannel();Execution Count:88 | 88 |
| 1298 | } executed: }Execution Count:202 | 202 |
| 1299 | | - |
| 1300 | /*! | - |
| 1301 | \since 4.2 | - |
| 1302 | | - |
| 1303 | Redirects the process' standard input to the file indicated by \a | - |
| 1304 | fileName. When an input redirection is in place, the QProcess | - |
| 1305 | object will be in read-only mode (calling write() will result in | - |
| 1306 | error). | - |
| 1307 | | - |
| 1308 | If the file \a fileName does not exist at the moment start() is | - |
| 1309 | called or is not readable, starting the process will fail. | - |
| 1310 | | - |
| 1311 | Calling setStandardInputFile() after the process has started has no | - |
| 1312 | effect. | - |
| 1313 | | - |
| 1314 | \sa setStandardOutputFile(), setStandardErrorFile(), | - |
| 1315 | setStandardOutputProcess() | - |
| 1316 | */ | - |
| 1317 | void QProcess::setStandardInputFile(const QString &fileName) | - |
| 1318 | { | - |
| 1319 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1320 | d->stdinChannel = fileName; executed (the execution status of this line is deduced): d->stdinChannel = fileName; | - |
| 1321 | } executed: }Execution Count:1 | 1 |
| 1322 | | - |
| 1323 | /*! | - |
| 1324 | \since 4.2 | - |
| 1325 | | - |
| 1326 | Redirects the process' standard output to the file \a | - |
| 1327 | fileName. When the redirection is in place, the standard output | - |
| 1328 | read channel is closed: reading from it using read() will always | - |
| 1329 | fail, as will readAllStandardOutput(). | - |
| 1330 | | - |
| 1331 | If the file \a fileName doesn't exist at the moment start() is | - |
| 1332 | called, it will be created. If it cannot be created, the starting | - |
| 1333 | will fail. | - |
| 1334 | | - |
| 1335 | If the file exists and \a mode is QIODevice::Truncate, the file | - |
| 1336 | will be truncated. Otherwise (if \a mode is QIODevice::Append), | - |
| 1337 | the file will be appended to. | - |
| 1338 | | - |
| 1339 | Calling setStandardOutputFile() after the process has started has | - |
| 1340 | no effect. | - |
| 1341 | | - |
| 1342 | \sa setStandardInputFile(), setStandardErrorFile(), | - |
| 1343 | setStandardOutputProcess() | - |
| 1344 | */ | - |
| 1345 | void QProcess::setStandardOutputFile(const QString &fileName, OpenMode mode) | - |
| 1346 | { | - |
| 1347 | Q_ASSERT(mode == Append || mode == Truncate); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1348 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1349 | | - |
| 1350 | d->stdoutChannel = fileName; executed (the execution status of this line is deduced): d->stdoutChannel = fileName; | - |
| 1351 | d->stdoutChannel.append = mode == Append; executed (the execution status of this line is deduced): d->stdoutChannel.append = mode == Append; | - |
| 1352 | } executed: }Execution Count:4 | 4 |
| 1353 | | - |
| 1354 | /*! | - |
| 1355 | \since 4.2 | - |
| 1356 | | - |
| 1357 | Redirects the process' standard error to the file \a | - |
| 1358 | fileName. When the redirection is in place, the standard error | - |
| 1359 | read channel is closed: reading from it using read() will always | - |
| 1360 | fail, as will readAllStandardError(). The file will be appended to | - |
| 1361 | if \a mode is Append, otherwise, it will be truncated. | - |
| 1362 | | - |
| 1363 | See setStandardOutputFile() for more information on how the file | - |
| 1364 | is opened. | - |
| 1365 | | - |
| 1366 | Note: if setProcessChannelMode() was called with an argument of | - |
| 1367 | QProcess::MergedChannels, this function has no effect. | - |
| 1368 | | - |
| 1369 | \sa setStandardInputFile(), setStandardOutputFile(), | - |
| 1370 | setStandardOutputProcess() | - |
| 1371 | */ | - |
| 1372 | void QProcess::setStandardErrorFile(const QString &fileName, OpenMode mode) | - |
| 1373 | { | - |
| 1374 | Q_ASSERT(mode == Append || mode == Truncate); executed (the execution status of this line is deduced): qt_noop(); | - |
| 1375 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1376 | | - |
| 1377 | d->stderrChannel = fileName; executed (the execution status of this line is deduced): d->stderrChannel = fileName; | - |
| 1378 | d->stderrChannel.append = mode == Append; executed (the execution status of this line is deduced): d->stderrChannel.append = mode == Append; | - |
| 1379 | } executed: }Execution Count:2 | 2 |
| 1380 | | - |
| 1381 | /*! | - |
| 1382 | \since 4.2 | - |
| 1383 | | - |
| 1384 | Pipes the standard output stream of this process to the \a | - |
| 1385 | destination process' standard input. | - |
| 1386 | | - |
| 1387 | The following shell command: | - |
| 1388 | \snippet code/src_corelib_io_qprocess.cpp 2 | - |
| 1389 | | - |
| 1390 | Can be accomplished with QProcesses with the following code: | - |
| 1391 | \snippet code/src_corelib_io_qprocess.cpp 3 | - |
| 1392 | */ | - |
| 1393 | void QProcess::setStandardOutputProcess(QProcess *destination) | - |
| 1394 | { | - |
| 1395 | QProcessPrivate *dfrom = d_func(); executed (the execution status of this line is deduced): QProcessPrivate *dfrom = d_func(); | - |
| 1396 | QProcessPrivate *dto = destination->d_func(); executed (the execution status of this line is deduced): QProcessPrivate *dto = destination->d_func(); | - |
| 1397 | dfrom->stdoutChannel.pipeTo(dto); executed (the execution status of this line is deduced): dfrom->stdoutChannel.pipeTo(dto); | - |
| 1398 | dto->stdinChannel.pipeFrom(dfrom); executed (the execution status of this line is deduced): dto->stdinChannel.pipeFrom(dfrom); | - |
| 1399 | } executed: }Execution Count:2 | 2 |
| 1400 | | - |
| 1401 | #if defined(Q_OS_WIN) | - |
| 1402 | | - |
| 1403 | /*! | - |
| 1404 | \since 4.7 | - |
| 1405 | | - |
| 1406 | Returns the additional native command line arguments for the program. | - |
| 1407 | | - |
| 1408 | \note This function is available only on the Windows platform. | - |
| 1409 | | - |
| 1410 | \sa setNativeArguments() | - |
| 1411 | */ | - |
| 1412 | QString QProcess::nativeArguments() const | - |
| 1413 | { | - |
| 1414 | Q_D(const QProcess); | - |
| 1415 | return d->nativeArguments; | - |
| 1416 | } | - |
| 1417 | | - |
| 1418 | /*! | - |
| 1419 | \since 4.7 | - |
| 1420 | \overload | - |
| 1421 | | - |
| 1422 | Sets additional native command line \a arguments for the program. | - |
| 1423 | | - |
| 1424 | On operating systems where the system API for passing command line | - |
| 1425 | \a arguments to a subprocess natively uses a single string, one can | - |
| 1426 | conceive command lines which cannot be passed via QProcess's portable | - |
| 1427 | list-based API. In such cases this function must be used to set a | - |
| 1428 | string which is \e appended to the string composed from the usual | - |
| 1429 | argument list, with a delimiting space. | - |
| 1430 | | - |
| 1431 | \note This function is available only on the Windows platform. | - |
| 1432 | | - |
| 1433 | \sa nativeArguments() | - |
| 1434 | */ | - |
| 1435 | void QProcess::setNativeArguments(const QString &arguments) | - |
| 1436 | { | - |
| 1437 | Q_D(QProcess); | - |
| 1438 | d->nativeArguments = arguments; | - |
| 1439 | } | - |
| 1440 | | - |
| 1441 | #endif | - |
| 1442 | | - |
| 1443 | /*! | - |
| 1444 | If QProcess has been assigned a working directory, this function returns | - |
| 1445 | the working directory that the QProcess will enter before the program has | - |
| 1446 | started. Otherwise, (i.e., no directory has been assigned,) an empty | - |
| 1447 | string is returned, and QProcess will use the application's current | - |
| 1448 | working directory instead. | - |
| 1449 | | - |
| 1450 | \sa setWorkingDirectory() | - |
| 1451 | */ | - |
| 1452 | QString QProcess::workingDirectory() const | - |
| 1453 | { | - |
| 1454 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1455 | return d->workingDirectory; executed: return d->workingDirectory;Execution Count:1 | 1 |
| 1456 | } | - |
| 1457 | | - |
| 1458 | /*! | - |
| 1459 | Sets the working directory to \a dir. QProcess will start the | - |
| 1460 | process in this directory. The default behavior is to start the | - |
| 1461 | process in the working directory of the calling process. | - |
| 1462 | | - |
| 1463 | \note On QNX, this may cause all application threads to | - |
| 1464 | temporarily freeze. | - |
| 1465 | | - |
| 1466 | \sa workingDirectory(), start() | - |
| 1467 | */ | - |
| 1468 | void QProcess::setWorkingDirectory(const QString &dir) | - |
| 1469 | { | - |
| 1470 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1471 | d->workingDirectory = dir; executed (the execution status of this line is deduced): d->workingDirectory = dir; | - |
| 1472 | } executed: }Execution Count:75 | 75 |
| 1473 | | - |
| 1474 | /*! | - |
| 1475 | Returns the native process identifier for the running process, if | - |
| 1476 | available. If no process is currently running, 0 is returned. | - |
| 1477 | */ | - |
| 1478 | Q_PID QProcess::pid() const | - |
| 1479 | { | - |
| 1480 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1481 | return d->pid; executed: return d->pid;Execution Count:1 | 1 |
| 1482 | } | - |
| 1483 | | - |
| 1484 | /*! \reimp | - |
| 1485 | | - |
| 1486 | This function operates on the current read channel. | - |
| 1487 | | - |
| 1488 | \sa readChannel(), setReadChannel() | - |
| 1489 | */ | - |
| 1490 | bool QProcess::canReadLine() const | - |
| 1491 | { | - |
| 1492 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1493 | const QRingBuffer *readBuffer = (d->processChannel == QProcess::StandardError) partially evaluated: (d->processChannel == QProcess::StandardError)| no Evaluation Count:0 | yes Evaluation Count:17 |
| 0-17 |
| 1494 | ? &d->errorReadBuffer executed (the execution status of this line is deduced): ? &d->errorReadBuffer | - |
| 1495 | : &d->outputReadBuffer; executed (the execution status of this line is deduced): : &d->outputReadBuffer; | - |
| 1496 | return readBuffer->canReadLine() || QIODevice::canReadLine(); executed: return readBuffer->canReadLine() || QIODevice::canReadLine();Execution Count:17 | 17 |
| 1497 | } | - |
| 1498 | | - |
| 1499 | /*! | - |
| 1500 | Closes all communication with the process and kills it. After calling this | - |
| 1501 | function, QProcess will no longer emit readyRead(), and data can no | - |
| 1502 | longer be read or written. | - |
| 1503 | */ | - |
| 1504 | void QProcess::close() | - |
| 1505 | { | - |
| 1506 | emit aboutToClose(); executed (the execution status of this line is deduced): aboutToClose(); | - |
| 1507 | while (waitForBytesWritten(-1)) partially evaluated: waitForBytesWritten(-1)| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 1508 | ; | 0 |
| 1509 | kill(); executed (the execution status of this line is deduced): kill(); | - |
| 1510 | waitForFinished(-1); executed (the execution status of this line is deduced): waitForFinished(-1); | - |
| 1511 | QIODevice::close(); executed (the execution status of this line is deduced): QIODevice::close(); | - |
| 1512 | } executed: }Execution Count:4 | 4 |
| 1513 | | - |
| 1514 | /*! \reimp | - |
| 1515 | | - |
| 1516 | Returns true if the process is not running, and no more data is available | - |
| 1517 | for reading; otherwise returns false. | - |
| 1518 | */ | - |
| 1519 | bool QProcess::atEnd() const | - |
| 1520 | { | - |
| 1521 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1522 | const QRingBuffer *readBuffer = (d->processChannel == QProcess::StandardError) partially evaluated: (d->processChannel == QProcess::StandardError)| no Evaluation Count:0 | yes Evaluation Count:61 |
| 0-61 |
| 1523 | ? &d->errorReadBuffer executed (the execution status of this line is deduced): ? &d->errorReadBuffer | - |
| 1524 | : &d->outputReadBuffer; executed (the execution status of this line is deduced): : &d->outputReadBuffer; | - |
| 1525 | return QIODevice::atEnd() && (!isOpen() || readBuffer->isEmpty()); executed: return QIODevice::atEnd() && (!isOpen() || readBuffer->isEmpty());Execution Count:61 | 61 |
| 1526 | } | - |
| 1527 | | - |
| 1528 | /*! \reimp | - |
| 1529 | */ | - |
| 1530 | bool QProcess::isSequential() const | - |
| 1531 | { | - |
| 1532 | return true; executed: return true;Execution Count:1290 | 1290 |
| 1533 | } | - |
| 1534 | | - |
| 1535 | /*! \reimp | - |
| 1536 | */ | - |
| 1537 | qint64 QProcess::bytesAvailable() const | - |
| 1538 | { | - |
| 1539 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1540 | const QRingBuffer *readBuffer = (d->processChannel == QProcess::StandardError) evaluated: (d->processChannel == QProcess::StandardError)| yes Evaluation Count:15 | yes Evaluation Count:736 |
| 15-736 |
| 1541 | ? &d->errorReadBuffer executed (the execution status of this line is deduced): ? &d->errorReadBuffer | - |
| 1542 | : &d->outputReadBuffer; executed (the execution status of this line is deduced): : &d->outputReadBuffer; | - |
| 1543 | #if defined QPROCESS_DEBUG | - |
| 1544 | qDebug("QProcess::bytesAvailable() == %i (%s)", readBuffer->size(), | - |
| 1545 | (d->processChannel == QProcess::StandardError) ? "stderr" : "stdout"); | - |
| 1546 | #endif | - |
| 1547 | return readBuffer->size() + QIODevice::bytesAvailable(); executed: return readBuffer->size() + QIODevice::bytesAvailable();Execution Count:751 | 751 |
| 1548 | } | - |
| 1549 | | - |
| 1550 | /*! \reimp | - |
| 1551 | */ | - |
| 1552 | qint64 QProcess::bytesToWrite() const | - |
| 1553 | { | - |
| 1554 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1555 | qint64 size = d->writeBuffer.size(); executed (the execution status of this line is deduced): qint64 size = d->writeBuffer.size(); | - |
| 1556 | #ifdef Q_OS_WIN | - |
| 1557 | size += d->pipeWriterBytesToWrite(); | - |
| 1558 | #endif | - |
| 1559 | return size; executed: return size;Execution Count:837 | 837 |
| 1560 | } | - |
| 1561 | | - |
| 1562 | /*! | - |
| 1563 | Returns the type of error that occurred last. | - |
| 1564 | | - |
| 1565 | \sa state() | - |
| 1566 | */ | - |
| 1567 | QProcess::ProcessError QProcess::error() const | - |
| 1568 | { | - |
| 1569 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1570 | return d->processError; executed: return d->processError;Execution Count:768 | 768 |
| 1571 | } | - |
| 1572 | | - |
| 1573 | /*! | - |
| 1574 | Returns the current state of the process. | - |
| 1575 | | - |
| 1576 | \sa stateChanged(), error() | - |
| 1577 | */ | - |
| 1578 | QProcess::ProcessState QProcess::state() const | - |
| 1579 | { | - |
| 1580 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1581 | return d->processState; executed: return d->processState;Execution Count:82 | 82 |
| 1582 | } | - |
| 1583 | | - |
| 1584 | /*! | - |
| 1585 | \deprecated | - |
| 1586 | Sets the environment that QProcess will use when starting a process to the | - |
| 1587 | \a environment specified which consists of a list of key=value pairs. | - |
| 1588 | | - |
| 1589 | For example, the following code adds the \c{C:\\BIN} directory to the list of | - |
| 1590 | executable paths (\c{PATHS}) on Windows: | - |
| 1591 | | - |
| 1592 | \snippet qprocess-environment/main.cpp 0 | - |
| 1593 | | - |
| 1594 | \note This function is less efficient than the setProcessEnvironment() | - |
| 1595 | function. | - |
| 1596 | | - |
| 1597 | \sa environment(), setProcessEnvironment(), systemEnvironment() | - |
| 1598 | */ | - |
| 1599 | void QProcess::setEnvironment(const QStringList &environment) | - |
| 1600 | { | - |
| 1601 | setProcessEnvironment(QProcessEnvironmentPrivate::fromList(environment)); executed (the execution status of this line is deduced): setProcessEnvironment(QProcessEnvironmentPrivate::fromList(environment)); | - |
| 1602 | } executed: }Execution Count:87 | 87 |
| 1603 | | - |
| 1604 | /*! | - |
| 1605 | \deprecated | - |
| 1606 | Returns the environment that QProcess will use when starting a | - |
| 1607 | process, or an empty QStringList if no environment has been set | - |
| 1608 | using setEnvironment() or setEnvironmentHash(). If no environment | - |
| 1609 | has been set, the environment of the calling process will be used. | - |
| 1610 | | - |
| 1611 | \note The environment settings are ignored on Windows CE, | - |
| 1612 | as there is no concept of an environment. | - |
| 1613 | | - |
| 1614 | \sa processEnvironment(), setEnvironment(), systemEnvironment() | - |
| 1615 | */ | - |
| 1616 | QStringList QProcess::environment() const | - |
| 1617 | { | - |
| 1618 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1619 | return d->environment.toStringList(); executed: return d->environment.toStringList();Execution Count:1 | 1 |
| 1620 | } | - |
| 1621 | | - |
| 1622 | /*! | - |
| 1623 | \since 4.6 | - |
| 1624 | Sets the environment that QProcess will use when starting a process to the | - |
| 1625 | \a environment object. | - |
| 1626 | | - |
| 1627 | For example, the following code adds the \c{C:\\BIN} directory to the list of | - |
| 1628 | executable paths (\c{PATHS}) on Windows and sets \c{TMPDIR}: | - |
| 1629 | | - |
| 1630 | \snippet qprocess-environment/main.cpp 1 | - |
| 1631 | | - |
| 1632 | Note how, on Windows, environment variable names are case-insensitive. | - |
| 1633 | | - |
| 1634 | \sa processEnvironment(), QProcessEnvironment::systemEnvironment(), setEnvironment() | - |
| 1635 | */ | - |
| 1636 | void QProcess::setProcessEnvironment(const QProcessEnvironment &environment) | - |
| 1637 | { | - |
| 1638 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1639 | d->environment = environment; executed (the execution status of this line is deduced): d->environment = environment; | - |
| 1640 | } executed: }Execution Count:742 | 742 |
| 1641 | | - |
| 1642 | /*! | - |
| 1643 | \since 4.6 | - |
| 1644 | Returns the environment that QProcess will use when starting a | - |
| 1645 | process, or an empty object if no environment has been set using | - |
| 1646 | setEnvironment() or setProcessEnvironment(). If no environment has | - |
| 1647 | been set, the environment of the calling process will be used. | - |
| 1648 | | - |
| 1649 | \note The environment settings are ignored on Windows CE, | - |
| 1650 | as there is no concept of an environment. | - |
| 1651 | | - |
| 1652 | \sa setProcessEnvironment(), setEnvironment(), QProcessEnvironment::isEmpty() | - |
| 1653 | */ | - |
| 1654 | QProcessEnvironment QProcess::processEnvironment() const | - |
| 1655 | { | - |
| 1656 | Q_D(const QProcess); never executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 1657 | return d->environment; never executed: return d->environment; | 0 |
| 1658 | } | - |
| 1659 | | - |
| 1660 | /*! | - |
| 1661 | Blocks until the process has started and the started() signal has | - |
| 1662 | been emitted, or until \a msecs milliseconds have passed. | - |
| 1663 | | - |
| 1664 | Returns true if the process was started successfully; otherwise | - |
| 1665 | returns false (if the operation timed out or if an error | - |
| 1666 | occurred). | - |
| 1667 | | - |
| 1668 | This function can operate without an event loop. It is | - |
| 1669 | useful when writing non-GUI applications and when performing | - |
| 1670 | I/O operations in a non-GUI thread. | - |
| 1671 | | - |
| 1672 | \warning Calling this function from the main (GUI) thread | - |
| 1673 | might cause your user interface to freeze. | - |
| 1674 | | - |
| 1675 | If msecs is -1, this function will not time out. | - |
| 1676 | | - |
| 1677 | \sa started(), waitForReadyRead(), waitForBytesWritten(), waitForFinished() | - |
| 1678 | */ | - |
| 1679 | bool QProcess::waitForStarted(int msecs) | - |
| 1680 | { | - |
| 1681 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1682 | if (d->processState == QProcess::Running) partially evaluated: d->processState == QProcess::Running| no Evaluation Count:0 | yes Evaluation Count:2316 |
| 0-2316 |
| 1683 | return true; never executed: return true; | 0 |
| 1684 | | - |
| 1685 | return d->waitForStarted(msecs); executed: return d->waitForStarted(msecs);Execution Count:2316 | 2316 |
| 1686 | } | - |
| 1687 | | - |
| 1688 | /*! \reimp | - |
| 1689 | */ | - |
| 1690 | bool QProcess::waitForReadyRead(int msecs) | - |
| 1691 | { | - |
| 1692 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1693 | | - |
| 1694 | if (d->processState == QProcess::NotRunning) evaluated: d->processState == QProcess::NotRunning| yes Evaluation Count:1 | yes Evaluation Count:415 |
| 1-415 |
| 1695 | return false; executed: return false;Execution Count:1 | 1 |
| 1696 | if (d->processChannel == QProcess::StandardOutput && d->stdoutChannel.closed) evaluated: d->processChannel == QProcess::StandardOutput| yes Evaluation Count:399 | yes Evaluation Count:16 |
evaluated: d->stdoutChannel.closed| yes Evaluation Count:5 | yes Evaluation Count:394 |
| 5-399 |
| 1697 | return false; executed: return false;Execution Count:5 | 5 |
| 1698 | if (d->processChannel == QProcess::StandardError && d->stderrChannel.closed) evaluated: d->processChannel == QProcess::StandardError| yes Evaluation Count:16 | yes Evaluation Count:394 |
evaluated: d->stderrChannel.closed| yes Evaluation Count:5 | yes Evaluation Count:11 |
| 5-394 |
| 1699 | return false; executed: return false;Execution Count:5 | 5 |
| 1700 | return d->waitForReadyRead(msecs); executed: return d->waitForReadyRead(msecs);Execution Count:405 | 405 |
| 1701 | } | - |
| 1702 | | - |
| 1703 | /*! \reimp | - |
| 1704 | */ | - |
| 1705 | bool QProcess::waitForBytesWritten(int msecs) | - |
| 1706 | { | - |
| 1707 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1708 | if (d->processState == QProcess::NotRunning) evaluated: d->processState == QProcess::NotRunning| yes Evaluation Count:1 | yes Evaluation Count:830 |
| 1-830 |
| 1709 | return false; executed: return false;Execution Count:1 | 1 |
| 1710 | if (d->processState == QProcess::Starting) { evaluated: d->processState == QProcess::Starting| yes Evaluation Count:201 | yes Evaluation Count:629 |
| 201-629 |
| 1711 | QElapsedTimer stopWatch; executed (the execution status of this line is deduced): QElapsedTimer stopWatch; | - |
| 1712 | stopWatch.start(); executed (the execution status of this line is deduced): stopWatch.start(); | - |
| 1713 | bool started = waitForStarted(msecs); executed (the execution status of this line is deduced): bool started = waitForStarted(msecs); | - |
| 1714 | if (!started) evaluated: !started| yes Evaluation Count:100 | yes Evaluation Count:101 |
| 100-101 |
| 1715 | return false; executed: return false;Execution Count:100 | 100 |
| 1716 | if (msecs != -1) partially evaluated: msecs != -1| yes Evaluation Count:101 | no Evaluation Count:0 |
| 0-101 |
| 1717 | msecs -= stopWatch.elapsed(); executed: msecs -= stopWatch.elapsed();Execution Count:101 | 101 |
| 1718 | } executed: }Execution Count:101 | 101 |
| 1719 | | - |
| 1720 | return d->waitForBytesWritten(msecs); executed: return d->waitForBytesWritten(msecs);Execution Count:730 | 730 |
| 1721 | } | - |
| 1722 | | - |
| 1723 | /*! | - |
| 1724 | Blocks until the process has finished and the finished() signal | - |
| 1725 | has been emitted, or until \a msecs milliseconds have passed. | - |
| 1726 | | - |
| 1727 | Returns true if the process finished; otherwise returns false (if | - |
| 1728 | the operation timed out, if an error occurred, or if this QProcess | - |
| 1729 | is already finished). | - |
| 1730 | | - |
| 1731 | This function can operate without an event loop. It is | - |
| 1732 | useful when writing non-GUI applications and when performing | - |
| 1733 | I/O operations in a non-GUI thread. | - |
| 1734 | | - |
| 1735 | \warning Calling this function from the main (GUI) thread | - |
| 1736 | might cause your user interface to freeze. | - |
| 1737 | | - |
| 1738 | If msecs is -1, this function will not time out. | - |
| 1739 | | - |
| 1740 | \sa finished(), waitForStarted(), waitForReadyRead(), waitForBytesWritten() | - |
| 1741 | */ | - |
| 1742 | bool QProcess::waitForFinished(int msecs) | - |
| 1743 | { | - |
| 1744 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1745 | if (d->processState == QProcess::NotRunning) evaluated: d->processState == QProcess::NotRunning| yes Evaluation Count:2 | yes Evaluation Count:1830 |
| 2-1830 |
| 1746 | return false; executed: return false;Execution Count:2 | 2 |
| 1747 | if (d->processState == QProcess::Starting) { evaluated: d->processState == QProcess::Starting| yes Evaluation Count:590 | yes Evaluation Count:1240 |
| 590-1240 |
| 1748 | QElapsedTimer stopWatch; executed (the execution status of this line is deduced): QElapsedTimer stopWatch; | - |
| 1749 | stopWatch.start(); executed (the execution status of this line is deduced): stopWatch.start(); | - |
| 1750 | bool started = waitForStarted(msecs); executed (the execution status of this line is deduced): bool started = waitForStarted(msecs); | - |
| 1751 | if (!started) evaluated: !started| yes Evaluation Count:185 | yes Evaluation Count:405 |
| 185-405 |
| 1752 | return false; executed: return false;Execution Count:185 | 185 |
| 1753 | if (msecs != -1) evaluated: msecs != -1| yes Evaluation Count:404 | yes Evaluation Count:1 |
| 1-404 |
| 1754 | msecs -= stopWatch.elapsed(); executed: msecs -= stopWatch.elapsed();Execution Count:404 | 404 |
| 1755 | } executed: }Execution Count:405 | 405 |
| 1756 | | - |
| 1757 | return d->waitForFinished(msecs); executed: return d->waitForFinished(msecs);Execution Count:1645 | 1645 |
| 1758 | } | - |
| 1759 | | - |
| 1760 | /*! | - |
| 1761 | Sets the current state of the QProcess to the \a state specified. | - |
| 1762 | | - |
| 1763 | \sa state() | - |
| 1764 | */ | - |
| 1765 | void QProcess::setProcessState(ProcessState state) | - |
| 1766 | { | - |
| 1767 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1768 | if (d->processState == state) evaluated: d->processState == state| yes Evaluation Count:2551 | yes Evaluation Count:6733 |
| 2551-6733 |
| 1769 | return; executed: return;Execution Count:2551 | 2551 |
| 1770 | d->processState = state; executed (the execution status of this line is deduced): d->processState = state; | - |
| 1771 | emit stateChanged(state, QPrivateSignal()); executed (the execution status of this line is deduced): stateChanged(state, QPrivateSignal()); | - |
| 1772 | } executed: }Execution Count:6733 | 6733 |
| 1773 | | - |
| 1774 | /*! | - |
| 1775 | This function is called in the child process context just before the | - |
| 1776 | program is executed on Unix or Mac OS X (i.e., after \e fork(), but before | - |
| 1777 | \e execve()). Reimplement this function to do last minute initialization | - |
| 1778 | of the child process. Example: | - |
| 1779 | | - |
| 1780 | \snippet code/src_corelib_io_qprocess.cpp 4 | - |
| 1781 | | - |
| 1782 | You cannot exit the process (by calling exit(), for instance) from | - |
| 1783 | this function. If you need to stop the program before it starts | - |
| 1784 | execution, your workaround is to emit finished() and then call | - |
| 1785 | exit(). | - |
| 1786 | | - |
| 1787 | \warning This function is called by QProcess on Unix and Mac OS X | - |
| 1788 | only. On Windows and QNX, it is not called. | - |
| 1789 | */ | - |
| 1790 | void QProcess::setupChildProcess() | - |
| 1791 | { | - |
| 1792 | } | - |
| 1793 | | - |
| 1794 | /*! \reimp | - |
| 1795 | */ | - |
| 1796 | qint64 QProcess::readData(char *data, qint64 maxlen) | - |
| 1797 | { | - |
| 1798 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1799 | if (!maxlen) evaluated: !maxlen| yes Evaluation Count:1468 | yes Evaluation Count:2822 |
| 1468-2822 |
| 1800 | return 0; executed: return 0;Execution Count:1468 | 1468 |
| 1801 | QRingBuffer *readBuffer = (d->processChannel == QProcess::StandardError) evaluated: (d->processChannel == QProcess::StandardError)| yes Evaluation Count:831 | yes Evaluation Count:1991 |
| 831-1991 |
| 1802 | ? &d->errorReadBuffer executed (the execution status of this line is deduced): ? &d->errorReadBuffer | - |
| 1803 | : &d->outputReadBuffer; executed (the execution status of this line is deduced): : &d->outputReadBuffer; | - |
| 1804 | | - |
| 1805 | if (maxlen == 1 && !readBuffer->isEmpty()) { partially evaluated: maxlen == 1| no Evaluation Count:0 | yes Evaluation Count:2822 |
never evaluated: !readBuffer->isEmpty() | 0-2822 |
| 1806 | int c = readBuffer->getChar(); never executed (the execution status of this line is deduced): int c = readBuffer->getChar(); | - |
| 1807 | if (c == -1) { | 0 |
| 1808 | #if defined QPROCESS_DEBUG | - |
| 1809 | qDebug("QProcess::readData(%p \"%s\", %d) == -1", | - |
| 1810 | data, qt_prettyDebug(data, 1, maxlen).constData(), 1); | - |
| 1811 | #endif | - |
| 1812 | return -1; never executed: return -1; | 0 |
| 1813 | } | - |
| 1814 | *data = (char) c; never executed (the execution status of this line is deduced): *data = (char) c; | - |
| 1815 | #if defined QPROCESS_DEBUG | - |
| 1816 | qDebug("QProcess::readData(%p \"%s\", %d) == 1", | - |
| 1817 | data, qt_prettyDebug(data, 1, maxlen).constData(), 1); | - |
| 1818 | #endif | - |
| 1819 | return 1; never executed: return 1; | 0 |
| 1820 | } | - |
| 1821 | | - |
| 1822 | qint64 bytesToRead = qint64(qMin(readBuffer->size(), (int)maxlen)); executed (the execution status of this line is deduced): qint64 bytesToRead = qint64(qMin(readBuffer->size(), (int)maxlen)); | - |
| 1823 | qint64 readSoFar = 0; executed (the execution status of this line is deduced): qint64 readSoFar = 0; | - |
| 1824 | while (readSoFar < bytesToRead) { evaluated: readSoFar < bytesToRead| yes Evaluation Count:1601 | yes Evaluation Count:2822 |
| 1601-2822 |
| 1825 | const char *ptr = readBuffer->readPointer(); executed (the execution status of this line is deduced): const char *ptr = readBuffer->readPointer(); | - |
| 1826 | int bytesToReadFromThisBlock = qMin<qint64>(bytesToRead - readSoFar, executed (the execution status of this line is deduced): int bytesToReadFromThisBlock = qMin<qint64>(bytesToRead - readSoFar, | - |
| 1827 | readBuffer->nextDataBlockSize()); executed (the execution status of this line is deduced): readBuffer->nextDataBlockSize()); | - |
| 1828 | memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock); executed (the execution status of this line is deduced): memcpy(data + readSoFar, ptr, bytesToReadFromThisBlock); | - |
| 1829 | readSoFar += bytesToReadFromThisBlock; executed (the execution status of this line is deduced): readSoFar += bytesToReadFromThisBlock; | - |
| 1830 | readBuffer->free(bytesToReadFromThisBlock); executed (the execution status of this line is deduced): readBuffer->free(bytesToReadFromThisBlock); | - |
| 1831 | } executed: }Execution Count:1601 | 1601 |
| 1832 | | - |
| 1833 | #if defined QPROCESS_DEBUG | - |
| 1834 | qDebug("QProcess::readData(%p \"%s\", %lld) == %lld", | - |
| 1835 | data, qt_prettyDebug(data, readSoFar, 16).constData(), maxlen, readSoFar); | - |
| 1836 | #endif | - |
| 1837 | if (!readSoFar && d->processState == QProcess::NotRunning) evaluated: !readSoFar| yes Evaluation Count:1663 | yes Evaluation Count:1159 |
evaluated: d->processState == QProcess::NotRunning| yes Evaluation Count:1327 | yes Evaluation Count:336 |
| 336-1663 |
| 1838 | return -1; // EOF executed: return -1;Execution Count:1327 | 1327 |
| 1839 | return readSoFar; executed: return readSoFar;Execution Count:1495 | 1495 |
| 1840 | } | - |
| 1841 | | - |
| 1842 | /*! \reimp | - |
| 1843 | */ | - |
| 1844 | qint64 QProcess::writeData(const char *data, qint64 len) | - |
| 1845 | { | - |
| 1846 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1847 | | - |
| 1848 | #if defined(Q_OS_WINCE) | - |
| 1849 | Q_UNUSED(data); | - |
| 1850 | Q_UNUSED(len); | - |
| 1851 | d->processError = QProcess::WriteError; | - |
| 1852 | setErrorString(tr("Error writing to process")); | - |
| 1853 | emit error(d->processError); | - |
| 1854 | return -1; | - |
| 1855 | #endif | - |
| 1856 | | - |
| 1857 | if (d->stdinChannel.closed) { evaluated: d->stdinChannel.closed| yes Evaluation Count:1 | yes Evaluation Count:454 |
| 1-454 |
| 1858 | #if defined QPROCESS_DEBUG | - |
| 1859 | qDebug("QProcess::writeData(%p \"%s\", %lld) == 0 (write channel closing)", | - |
| 1860 | data, qt_prettyDebug(data, len, 16).constData(), len); | - |
| 1861 | #endif | - |
| 1862 | return 0; executed: return 0;Execution Count:1 | 1 |
| 1863 | } | - |
| 1864 | | - |
| 1865 | if (len == 1) { evaluated: len == 1| yes Evaluation Count:34 | yes Evaluation Count:420 |
| 34-420 |
| 1866 | d->writeBuffer.putChar(*data); executed (the execution status of this line is deduced): d->writeBuffer.putChar(*data); | - |
| 1867 | if (d->stdinChannel.notifier) partially evaluated: d->stdinChannel.notifier| yes Evaluation Count:34 | no Evaluation Count:0 |
| 0-34 |
| 1868 | d->stdinChannel.notifier->setEnabled(true); executed: d->stdinChannel.notifier->setEnabled(true);Execution Count:34 | 34 |
| 1869 | #if defined QPROCESS_DEBUG | - |
| 1870 | qDebug("QProcess::writeData(%p \"%s\", %lld) == 1 (written to buffer)", | - |
| 1871 | data, qt_prettyDebug(data, len, 16).constData(), len); | - |
| 1872 | #endif | - |
| 1873 | return 1; executed: return 1;Execution Count:34 | 34 |
| 1874 | } | - |
| 1875 | | - |
| 1876 | char *dest = d->writeBuffer.reserve(len); executed (the execution status of this line is deduced): char *dest = d->writeBuffer.reserve(len); | - |
| 1877 | memcpy(dest, data, len); executed (the execution status of this line is deduced): memcpy(dest, data, len); | - |
| 1878 | if (d->stdinChannel.notifier) partially evaluated: d->stdinChannel.notifier| yes Evaluation Count:420 | no Evaluation Count:0 |
| 0-420 |
| 1879 | d->stdinChannel.notifier->setEnabled(true); executed: d->stdinChannel.notifier->setEnabled(true);Execution Count:420 | 420 |
| 1880 | #if defined QPROCESS_DEBUG | - |
| 1881 | qDebug("QProcess::writeData(%p \"%s\", %lld) == %lld (written to buffer)", | - |
| 1882 | data, qt_prettyDebug(data, len, 16).constData(), len, len); | - |
| 1883 | #endif | - |
| 1884 | return len; executed: return len;Execution Count:420 | 420 |
| 1885 | } | - |
| 1886 | | - |
| 1887 | /*! | - |
| 1888 | Regardless of the current read channel, this function returns all | - |
| 1889 | data available from the standard output of the process as a | - |
| 1890 | QByteArray. | - |
| 1891 | | - |
| 1892 | \sa readyReadStandardOutput(), readAllStandardError(), readChannel(), setReadChannel() | - |
| 1893 | */ | - |
| 1894 | QByteArray QProcess::readAllStandardOutput() | - |
| 1895 | { | - |
| 1896 | ProcessChannel tmp = readChannel(); executed (the execution status of this line is deduced): ProcessChannel tmp = readChannel(); | - |
| 1897 | setReadChannel(StandardOutput); executed (the execution status of this line is deduced): setReadChannel(StandardOutput); | - |
| 1898 | QByteArray data = readAll(); executed (the execution status of this line is deduced): QByteArray data = readAll(); | - |
| 1899 | setReadChannel(tmp); executed (the execution status of this line is deduced): setReadChannel(tmp); | - |
| 1900 | return data; executed: return data;Execution Count:500 | 500 |
| 1901 | } | - |
| 1902 | | - |
| 1903 | /*! | - |
| 1904 | Regardless of the current read channel, this function returns all | - |
| 1905 | data available from the standard error of the process as a | - |
| 1906 | QByteArray. | - |
| 1907 | | - |
| 1908 | \sa readyReadStandardError(), readAllStandardOutput(), readChannel(), setReadChannel() | - |
| 1909 | */ | - |
| 1910 | QByteArray QProcess::readAllStandardError() | - |
| 1911 | { | - |
| 1912 | ProcessChannel tmp = readChannel(); executed (the execution status of this line is deduced): ProcessChannel tmp = readChannel(); | - |
| 1913 | setReadChannel(StandardError); executed (the execution status of this line is deduced): setReadChannel(StandardError); | - |
| 1914 | QByteArray data = readAll(); executed (the execution status of this line is deduced): QByteArray data = readAll(); | - |
| 1915 | setReadChannel(tmp); executed (the execution status of this line is deduced): setReadChannel(tmp); | - |
| 1916 | return data; executed: return data;Execution Count:730 | 730 |
| 1917 | } | - |
| 1918 | | - |
| 1919 | /*! | - |
| 1920 | Starts the given \a program in a new process, if none is already | - |
| 1921 | running, passing the command line arguments in \a arguments. The OpenMode | - |
| 1922 | is set to \a mode. | - |
| 1923 | | - |
| 1924 | The QProcess object will immediately enter the Starting state. If the | - |
| 1925 | process starts successfully, QProcess will emit started(); otherwise, | - |
| 1926 | error() will be emitted. If the QProcess object is already running a | - |
| 1927 | process, a warning may be printed at the console, and the existing | - |
| 1928 | process will continue running. | - |
| 1929 | | - |
| 1930 | \note Processes are started asynchronously, which means the started() | - |
| 1931 | and error() signals may be delayed. Call waitForStarted() to make | - |
| 1932 | sure the process has started (or has failed to start) and those signals | - |
| 1933 | have been emitted. | - |
| 1934 | | - |
| 1935 | \note No further splitting of the arguments is performed. | - |
| 1936 | | - |
| 1937 | \b{Windows:} Arguments that contain spaces are wrapped in quotes. | - |
| 1938 | | - |
| 1939 | \sa pid(), started(), waitForStarted() | - |
| 1940 | */ | - |
| 1941 | void QProcess::start(const QString &program, const QStringList &arguments, OpenMode mode) | - |
| 1942 | { | - |
| 1943 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 1944 | if (d->processState != NotRunning) { partially evaluated: d->processState != NotRunning| no Evaluation Count:0 | yes Evaluation Count:2520 |
| 0-2520 |
| 1945 | qWarning("QProcess::start: Process is already running"); never executed (the execution status of this line is deduced): QMessageLogger("io/qprocess.cpp", 1945, __PRETTY_FUNCTION__).warning("QProcess::start: Process is already running"); | - |
| 1946 | return; | 0 |
| 1947 | } | - |
| 1948 | | - |
| 1949 | #if defined QPROCESS_DEBUG | - |
| 1950 | qDebug() << "QProcess::start(" << program << ',' << arguments << ',' << mode << ')'; | - |
| 1951 | #endif | - |
| 1952 | | - |
| 1953 | d->outputReadBuffer.clear(); executed (the execution status of this line is deduced): d->outputReadBuffer.clear(); | - |
| 1954 | d->errorReadBuffer.clear(); executed (the execution status of this line is deduced): d->errorReadBuffer.clear(); | - |
| 1955 | | - |
| 1956 | if (d->stdinChannel.type != QProcessPrivate::Channel::Normal) evaluated: d->stdinChannel.type != QProcessPrivate::Channel::Normal| yes Evaluation Count:3 | yes Evaluation Count:2517 |
| 3-2517 |
| 1957 | mode &= ~WriteOnly; // not open for writing executed: mode &= ~WriteOnly;Execution Count:3 | 3 |
| 1958 | if (d->stdoutChannel.type != QProcessPrivate::Channel::Normal && evaluated: d->stdoutChannel.type != QProcessPrivate::Channel::Normal| yes Evaluation Count:6 | yes Evaluation Count:2514 |
| 6-2514 |
| 1959 | (d->stderrChannel.type != QProcessPrivate::Channel::Normal || partially evaluated: d->stderrChannel.type != QProcessPrivate::Channel::Normal| no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
| 1960 | d->processChannelMode == MergedChannels)) evaluated: d->processChannelMode == MergedChannels| yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
| 1961 | mode &= ~ReadOnly; // not open for reading executed: mode &= ~ReadOnly;Execution Count:3 | 3 |
| 1962 | if (mode == 0) partially evaluated: mode == 0| no Evaluation Count:0 | yes Evaluation Count:2520 |
| 0-2520 |
| 1963 | mode = Unbuffered; never executed: mode = Unbuffered; | 0 |
| 1964 | QIODevice::open(mode); executed (the execution status of this line is deduced): QIODevice::open(mode); | - |
| 1965 | | - |
| 1966 | d->stdinChannel.closed = false; executed (the execution status of this line is deduced): d->stdinChannel.closed = false; | - |
| 1967 | d->stdoutChannel.closed = false; executed (the execution status of this line is deduced): d->stdoutChannel.closed = false; | - |
| 1968 | d->stderrChannel.closed = false; executed (the execution status of this line is deduced): d->stderrChannel.closed = false; | - |
| 1969 | | - |
| 1970 | d->program = program; executed (the execution status of this line is deduced): d->program = program; | - |
| 1971 | d->arguments = arguments; executed (the execution status of this line is deduced): d->arguments = arguments; | - |
| 1972 | | - |
| 1973 | d->exitCode = 0; executed (the execution status of this line is deduced): d->exitCode = 0; | - |
| 1974 | d->exitStatus = NormalExit; executed (the execution status of this line is deduced): d->exitStatus = NormalExit; | - |
| 1975 | d->processError = QProcess::UnknownError; executed (the execution status of this line is deduced): d->processError = QProcess::UnknownError; | - |
| 1976 | d->errorString.clear(); executed (the execution status of this line is deduced): d->errorString.clear(); | - |
| 1977 | d->startProcess(); executed (the execution status of this line is deduced): d->startProcess(); | - |
| 1978 | } executed: }Execution Count:2520 | 2520 |
| 1979 | | - |
| 1980 | | - |
| 1981 | static QStringList parseCombinedArgString(const QString &program) | - |
| 1982 | { | - |
| 1983 | QStringList args; executed (the execution status of this line is deduced): QStringList args; | - |
| 1984 | QString tmp; executed (the execution status of this line is deduced): QString tmp; | - |
| 1985 | int quoteCount = 0; executed (the execution status of this line is deduced): int quoteCount = 0; | - |
| 1986 | bool inQuote = false; executed (the execution status of this line is deduced): bool inQuote = false; | - |
| 1987 | | - |
| 1988 | // handle quoting. tokens can be surrounded by double quotes | - |
| 1989 | // "hello world". three consecutive double quotes represent | - |
| 1990 | // the quote character itself. | - |
| 1991 | for (int i = 0; i < program.size(); ++i) { evaluated: i < program.size()| yes Evaluation Count:25473 | yes Evaluation Count:1084 |
| 1084-25473 |
| 1992 | if (program.at(i) == QLatin1Char('"')) { evaluated: program.at(i) == QLatin1Char('"')| yes Evaluation Count:372 | yes Evaluation Count:25103 |
| 372-25103 |
| 1993 | ++quoteCount; executed (the execution status of this line is deduced): ++quoteCount; | - |
| 1994 | if (quoteCount == 3) { evaluated: quoteCount == 3| yes Evaluation Count:84 | yes Evaluation Count:288 |
| 84-288 |
| 1995 | // third consecutive quote | - |
| 1996 | quoteCount = 0; executed (the execution status of this line is deduced): quoteCount = 0; | - |
| 1997 | tmp += program.at(i); executed (the execution status of this line is deduced): tmp += program.at(i); | - |
| 1998 | } executed: }Execution Count:84 | 84 |
| 1999 | continue; executed: continue;Execution Count:372 | 372 |
| 2000 | } | - |
| 2001 | if (quoteCount) { evaluated: quoteCount| yes Evaluation Count:99 | yes Evaluation Count:25004 |
| 99-25004 |
| 2002 | if (quoteCount == 1) evaluated: quoteCount == 1| yes Evaluation Count:93 | yes Evaluation Count:6 |
| 6-93 |
| 2003 | inQuote = !inQuote; executed: inQuote = !inQuote;Execution Count:93 | 93 |
| 2004 | quoteCount = 0; executed (the execution status of this line is deduced): quoteCount = 0; | - |
| 2005 | } executed: }Execution Count:99 | 99 |
| 2006 | if (!inQuote && program.at(i).isSpace()) { evaluated: !inQuote| yes Evaluation Count:24208 | yes Evaluation Count:894 |
evaluated: program.at(i).isSpace()| yes Evaluation Count:348 | yes Evaluation Count:23859 |
| 348-24208 |
| 2007 | if (!tmp.isEmpty()) { evaluated: !tmp.isEmpty()| yes Evaluation Count:335 | yes Evaluation Count:13 |
| 13-335 |
| 2008 | args += tmp; executed (the execution status of this line is deduced): args += tmp; | - |
| 2009 | tmp.clear(); executed (the execution status of this line is deduced): tmp.clear(); | - |
| 2010 | } executed: }Execution Count:335 | 335 |
| 2011 | } else { executed: }Execution Count:348 | 348 |
| 2012 | tmp += program.at(i); executed (the execution status of this line is deduced): tmp += program.at(i); | - |
| 2013 | } executed: }Execution Count:24757 | 24757 |
| 2014 | } | - |
| 2015 | if (!tmp.isEmpty()) evaluated: !tmp.isEmpty()| yes Evaluation Count:1075 | yes Evaluation Count:9 |
| 9-1075 |
| 2016 | args += tmp; executed: args += tmp;Execution Count:1075 | 1075 |
| 2017 | | - |
| 2018 | return args; executed: return args;Execution Count:1085 | 1085 |
| 2019 | } | - |
| 2020 | | - |
| 2021 | /*! | - |
| 2022 | \overload | - |
| 2023 | | - |
| 2024 | Starts the command \a command in a new process, if one is not already | - |
| 2025 | running. \a command is a single string of text containing both the | - |
| 2026 | program name and its arguments. The arguments are separated by one or | - |
| 2027 | more spaces. For example: | - |
| 2028 | | - |
| 2029 | \snippet code/src_corelib_io_qprocess.cpp 5 | - |
| 2030 | | - |
| 2031 | The \a command string can also contain quotes, to ensure that arguments | - |
| 2032 | containing spaces are correctly supplied to the new process. For example: | - |
| 2033 | | - |
| 2034 | \snippet code/src_corelib_io_qprocess.cpp 6 | - |
| 2035 | | - |
| 2036 | If the QProcess object is already running a process, a warning may be | - |
| 2037 | printed at the console, and the existing process will continue running. | - |
| 2038 | | - |
| 2039 | Note that, on Windows, quotes need to be both escaped and quoted. | - |
| 2040 | For example, the above code would be specified in the following | - |
| 2041 | way to ensure that \c{"My Documents"} is used as the argument to | - |
| 2042 | the \c dir executable: | - |
| 2043 | | - |
| 2044 | \snippet code/src_corelib_io_qprocess.cpp 7 | - |
| 2045 | | - |
| 2046 | The OpenMode is set to \a mode. | - |
| 2047 | */ | - |
| 2048 | void QProcess::start(const QString &command, OpenMode mode) | - |
| 2049 | { | - |
| 2050 | QStringList args = parseCombinedArgString(command); executed (the execution status of this line is deduced): QStringList args = parseCombinedArgString(command); | - |
| 2051 | if (args.isEmpty()) { evaluated: args.isEmpty()| yes Evaluation Count:3 | yes Evaluation Count:1077 |
| 3-1077 |
| 2052 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 2053 | d->processError = QProcess::FailedToStart; executed (the execution status of this line is deduced): d->processError = QProcess::FailedToStart; | - |
| 2054 | setErrorString(tr("No program defined")); executed (the execution status of this line is deduced): setErrorString(tr("No program defined")); | - |
| 2055 | emit error(d->processError); executed (the execution status of this line is deduced): error(d->processError); | - |
| 2056 | return; executed: return;Execution Count:3 | 3 |
| 2057 | } | - |
| 2058 | | - |
| 2059 | QString prog = args.first(); executed (the execution status of this line is deduced): QString prog = args.first(); | - |
| 2060 | args.removeFirst(); executed (the execution status of this line is deduced): args.removeFirst(); | - |
| 2061 | | - |
| 2062 | start(prog, args, mode); executed (the execution status of this line is deduced): start(prog, args, mode); | - |
| 2063 | } executed: }Execution Count:1077 | 1077 |
| 2064 | | - |
| 2065 | /*! | - |
| 2066 | Returns the program the process was last started with. | - |
| 2067 | | - |
| 2068 | \sa start() | - |
| 2069 | */ | - |
| 2070 | QString QProcess::program() const | - |
| 2071 | { | - |
| 2072 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 2073 | return d->program; executed: return d->program;Execution Count:1 | 1 |
| 2074 | } | - |
| 2075 | | - |
| 2076 | /*! | - |
| 2077 | Returns the command line arguments the process was last started with. | - |
| 2078 | | - |
| 2079 | \sa start() | - |
| 2080 | */ | - |
| 2081 | QStringList QProcess::arguments() const | - |
| 2082 | { | - |
| 2083 | Q_D(const QProcess); never executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 2084 | return d->arguments; never executed: return d->arguments; | 0 |
| 2085 | } | - |
| 2086 | | - |
| 2087 | /*! | - |
| 2088 | Attempts to terminate the process. | - |
| 2089 | | - |
| 2090 | The process may not exit as a result of calling this function (it is given | - |
| 2091 | the chance to prompt the user for any unsaved files, etc). | - |
| 2092 | | - |
| 2093 | On Windows, terminate() posts a WM_CLOSE message to all toplevel windows | - |
| 2094 | of the process and then to the main thread of the process itself. On Unix | - |
| 2095 | and Mac OS X the SIGTERM signal is sent. | - |
| 2096 | | - |
| 2097 | Console applications on Windows that do not run an event loop, or whose | - |
| 2098 | event loop does not handle the WM_CLOSE message, can only be terminated by | - |
| 2099 | calling kill(). | - |
| 2100 | | - |
| 2101 | \sa kill() | - |
| 2102 | */ | - |
| 2103 | void QProcess::terminate() | - |
| 2104 | { | - |
| 2105 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 2106 | d->terminateProcess(); executed (the execution status of this line is deduced): d->terminateProcess(); | - |
| 2107 | } executed: }Execution Count:153 | 153 |
| 2108 | | - |
| 2109 | /*! | - |
| 2110 | Kills the current process, causing it to exit immediately. | - |
| 2111 | | - |
| 2112 | On Windows, kill() uses TerminateProcess, and on Unix and Mac OS X, the | - |
| 2113 | SIGKILL signal is sent to the process. | - |
| 2114 | | - |
| 2115 | \sa terminate() | - |
| 2116 | */ | - |
| 2117 | void QProcess::kill() | - |
| 2118 | { | - |
| 2119 | Q_D(QProcess); executed (the execution status of this line is deduced): QProcessPrivate * const d = d_func(); | - |
| 2120 | d->killProcess(); executed (the execution status of this line is deduced): d->killProcess(); | - |
| 2121 | } executed: }Execution Count:19 | 19 |
| 2122 | | - |
| 2123 | /*! | - |
| 2124 | Returns the exit code of the last process that finished. | - |
| 2125 | */ | - |
| 2126 | int QProcess::exitCode() const | - |
| 2127 | { | - |
| 2128 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 2129 | return d->exitCode; executed: return d->exitCode;Execution Count:555 | 555 |
| 2130 | } | - |
| 2131 | | - |
| 2132 | /*! | - |
| 2133 | \since 4.1 | - |
| 2134 | | - |
| 2135 | Returns the exit status of the last process that finished. | - |
| 2136 | | - |
| 2137 | On Windows, if the process was terminated with TerminateProcess() | - |
| 2138 | from another application this function will still return NormalExit | - |
| 2139 | unless the exit code is less than 0. | - |
| 2140 | */ | - |
| 2141 | QProcess::ExitStatus QProcess::exitStatus() const | - |
| 2142 | { | - |
| 2143 | Q_D(const QProcess); executed (the execution status of this line is deduced): const QProcessPrivate * const d = d_func(); | - |
| 2144 | return d->exitStatus; executed: return d->exitStatus;Execution Count:227 | 227 |
| 2145 | } | - |
| 2146 | | - |
| 2147 | /*! | - |
| 2148 | Starts the program \a program with the arguments \a arguments in a | - |
| 2149 | new process, waits for it to finish, and then returns the exit | - |
| 2150 | code of the process. Any data the new process writes to the | - |
| 2151 | console is forwarded to the calling process. | - |
| 2152 | | - |
| 2153 | The environment and working directory are inherited from the calling | - |
| 2154 | process. | - |
| 2155 | | - |
| 2156 | On Windows, arguments that contain spaces are wrapped in quotes. | - |
| 2157 | | - |
| 2158 | If the process cannot be started, -2 is returned. If the process | - |
| 2159 | crashes, -1 is returned. Otherwise, the process' exit code is | - |
| 2160 | returned. | - |
| 2161 | */ | - |
| 2162 | int QProcess::execute(const QString &program, const QStringList &arguments) | - |
| 2163 | { | - |
| 2164 | QProcess process; executed (the execution status of this line is deduced): QProcess process; | - |
| 2165 | process.setReadChannelMode(ForwardedChannels); executed (the execution status of this line is deduced): process.setReadChannelMode(ForwardedChannels); | - |
| 2166 | process.start(program, arguments); executed (the execution status of this line is deduced): process.start(program, arguments); | - |
| 2167 | if (!process.waitForFinished(-1)) partially evaluated: !process.waitForFinished(-1)| no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
| 2168 | return -2; never executed: return -2; | 0 |
| 2169 | return process.exitStatus() == QProcess::NormalExit ? process.exitCode() : -1; executed: return process.exitStatus() == QProcess::NormalExit ? process.exitCode() : -1;Execution Count:1 | 1 |
| 2170 | } | - |
| 2171 | | - |
| 2172 | /*! | - |
| 2173 | \overload | - |
| 2174 | | - |
| 2175 | Starts the program \a program in a new process. \a program is a | - |
| 2176 | single string of text containing both the program name and its | - |
| 2177 | arguments. The arguments are separated by one or more spaces. | - |
| 2178 | */ | - |
| 2179 | int QProcess::execute(const QString &program) | - |
| 2180 | { | - |
| 2181 | QProcess process; executed (the execution status of this line is deduced): QProcess process; | - |
| 2182 | process.setReadChannelMode(ForwardedChannels); executed (the execution status of this line is deduced): process.setReadChannelMode(ForwardedChannels); | - |
| 2183 | process.start(program); executed (the execution status of this line is deduced): process.start(program); | - |
| 2184 | if (!process.waitForFinished(-1)) partially evaluated: !process.waitForFinished(-1)| yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
| 2185 | return -2; executed: return -2;Execution Count:4 | 4 |
| 2186 | return process.exitStatus() == QProcess::NormalExit ? process.exitCode() : -1; never executed: return process.exitStatus() == QProcess::NormalExit ? process.exitCode() : -1; | 0 |
| 2187 | } | - |
| 2188 | | - |
| 2189 | /*! | - |
| 2190 | Starts the program \a program with the arguments \a arguments in a | - |
| 2191 | new process, and detaches from it. Returns true on success; | - |
| 2192 | otherwise returns false. If the calling process exits, the | - |
| 2193 | detached process will continue to live. | - |
| 2194 | | - |
| 2195 | Note that arguments that contain spaces are not passed to the | - |
| 2196 | process as separate arguments. | - |
| 2197 | | - |
| 2198 | \b{Unix:} The started process will run in its own session and act | - |
| 2199 | like a daemon. | - |
| 2200 | | - |
| 2201 | \b{Windows:} Arguments that contain spaces are wrapped in quotes. | - |
| 2202 | The started process will run as a regular standalone process. | - |
| 2203 | | - |
| 2204 | The process will be started in the directory \a workingDirectory. | - |
| 2205 | | - |
| 2206 | \note On QNX, this may cause all application threads to | - |
| 2207 | temporarily freeze. | - |
| 2208 | | - |
| 2209 | If the function is successful then *\a pid is set to the process | - |
| 2210 | identifier of the started process. | - |
| 2211 | */ | - |
| 2212 | bool QProcess::startDetached(const QString &program, | - |
| 2213 | const QStringList &arguments, | - |
| 2214 | const QString &workingDirectory, | - |
| 2215 | qint64 *pid) | - |
| 2216 | { | - |
| 2217 | return QProcessPrivate::startDetached(program, executed: return QProcessPrivate::startDetached(program, arguments, workingDirectory, pid);Execution Count:1 | 1 |
| 2218 | arguments, executed: return QProcessPrivate::startDetached(program, arguments, workingDirectory, pid);Execution Count:1 | 1 |
| 2219 | workingDirectory, executed: return QProcessPrivate::startDetached(program, arguments, workingDirectory, pid);Execution Count:1 | 1 |
| 2220 | pid); executed: return QProcessPrivate::startDetached(program, arguments, workingDirectory, pid);Execution Count:1 | 1 |
| 2221 | } | - |
| 2222 | | - |
| 2223 | /*! | - |
| 2224 | Starts the program \a program with the given \a arguments in a | - |
| 2225 | new process, and detaches from it. Returns true on success; | - |
| 2226 | otherwise returns false. If the calling process exits, the | - |
| 2227 | detached process will continue to live. | - |
| 2228 | | - |
| 2229 | \note Arguments that contain spaces are not passed to the | - |
| 2230 | process as separate arguments. | - |
| 2231 | | - |
| 2232 | \b{Unix:} The started process will run in its own session and act | - |
| 2233 | like a daemon. | - |
| 2234 | | - |
| 2235 | \b{Windows:} Arguments that contain spaces are wrapped in quotes. | - |
| 2236 | The started process will run as a regular standalone process. | - |
| 2237 | */ | - |
| 2238 | bool QProcess::startDetached(const QString &program, | - |
| 2239 | const QStringList &arguments) | - |
| 2240 | { | - |
| 2241 | return QProcessPrivate::startDetached(program, arguments); executed: return QProcessPrivate::startDetached(program, arguments);Execution Count:1 | 1 |
| 2242 | } | - |
| 2243 | | - |
| 2244 | /*! | - |
| 2245 | \overload | - |
| 2246 | | - |
| 2247 | Starts the program \a program in a new process. \a program is a | - |
| 2248 | single string of text containing both the program name and its | - |
| 2249 | arguments. The arguments are separated by one or more spaces. | - |
| 2250 | | - |
| 2251 | The \a program string can also contain quotes, to ensure that arguments | - |
| 2252 | containing spaces are correctly supplied to the new process. | - |
| 2253 | */ | - |
| 2254 | bool QProcess::startDetached(const QString &program) | - |
| 2255 | { | - |
| 2256 | QStringList args = parseCombinedArgString(program); executed (the execution status of this line is deduced): QStringList args = parseCombinedArgString(program); | - |
| 2257 | if (args.isEmpty()) evaluated: args.isEmpty()| yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
| 2258 | return false; executed: return false;Execution Count:3 | 3 |
| 2259 | | - |
| 2260 | QString prog = args.first(); executed (the execution status of this line is deduced): QString prog = args.first(); | - |
| 2261 | args.removeFirst(); executed (the execution status of this line is deduced): args.removeFirst(); | - |
| 2262 | | - |
| 2263 | return QProcessPrivate::startDetached(prog, args); executed: return QProcessPrivate::startDetached(prog, args);Execution Count:2 | 2 |
| 2264 | } | - |
| 2265 | | - |
| 2266 | QT_BEGIN_INCLUDE_NAMESPACE | - |
| 2267 | #if defined(Q_OS_MAC) && !defined(Q_OS_IOS) | - |
| 2268 | # include <crt_externs.h> | - |
| 2269 | # define environ (*_NSGetEnviron()) | - |
| 2270 | #elif defined(Q_OS_WINCE) || defined(Q_OS_IOS) | - |
| 2271 | static char *qt_empty_environ[] = { 0 }; | - |
| 2272 | #define environ qt_empty_environ | - |
| 2273 | #elif !defined(Q_OS_WIN) | - |
| 2274 | extern char **environ; | - |
| 2275 | #endif | - |
| 2276 | QT_END_INCLUDE_NAMESPACE | - |
| 2277 | | - |
| 2278 | /*! | - |
| 2279 | \since 4.1 | - |
| 2280 | | - |
| 2281 | Returns the environment of the calling process as a list of | - |
| 2282 | key=value pairs. Example: | - |
| 2283 | | - |
| 2284 | \snippet code/src_corelib_io_qprocess.cpp 8 | - |
| 2285 | | - |
| 2286 | This function does not cache the system environment. Therefore, it's | - |
| 2287 | possible to obtain an updated version of the environment if low-level C | - |
| 2288 | library functions like \tt setenv ot \tt putenv have been called. | - |
| 2289 | | - |
| 2290 | However, note that repeated calls to this function will recreate the | - |
| 2291 | list of environment variables, which is a non-trivial operation. | - |
| 2292 | | - |
| 2293 | \note For new code, it is recommended to use QProcessEnvironment::systemEnvironment() | - |
| 2294 | | - |
| 2295 | \sa QProcessEnvironment::systemEnvironment(), environment(), setEnvironment() | - |
| 2296 | */ | - |
| 2297 | QStringList QProcess::systemEnvironment() | - |
| 2298 | { | - |
| 2299 | QStringList tmp; executed (the execution status of this line is deduced): QStringList tmp; | - |
| 2300 | char *entry = 0; executed (the execution status of this line is deduced): char *entry = 0; | - |
| 2301 | int count = 0; executed (the execution status of this line is deduced): int count = 0; | - |
| 2302 | while ((entry = environ[count++])) evaluated: (entry = environ[count++])| yes Evaluation Count:1253 | yes Evaluation Count:55 |
| 55-1253 |
| 2303 | tmp << QString::fromLocal8Bit(entry); executed: tmp << QString::fromLocal8Bit(entry);Execution Count:1253 | 1253 |
| 2304 | return tmp; executed: return tmp;Execution Count:55 | 55 |
| 2305 | } | - |
| 2306 | | - |
| 2307 | /*! | - |
| 2308 | \fn QProcessEnvironment QProcessEnvironment::systemEnvironment() | - |
| 2309 | | - |
| 2310 | \since 4.6 | - |
| 2311 | | - |
| 2312 | \brief The systemEnvironment function returns the environment of | - |
| 2313 | the calling process. | - |
| 2314 | | - |
| 2315 | It is returned as a QProcessEnvironment. This function does not | - |
| 2316 | cache the system environment. Therefore, it's possible to obtain | - |
| 2317 | an updated version of the environment if low-level C library | - |
| 2318 | functions like \tt setenv ot \tt putenv have been called. | - |
| 2319 | | - |
| 2320 | However, note that repeated calls to this function will recreate the | - |
| 2321 | QProcessEnvironment object, which is a non-trivial operation. | - |
| 2322 | | - |
| 2323 | \sa QProcess::systemEnvironment() | - |
| 2324 | */ | - |
| 2325 | | - |
| 2326 | /*! | - |
| 2327 | \typedef Q_PID | - |
| 2328 | \relates QProcess | - |
| 2329 | | - |
| 2330 | Typedef for the identifiers used to represent processes on the underlying | - |
| 2331 | platform. On Unix, this corresponds to \l qint64; on Windows, it | - |
| 2332 | corresponds to \c{_PROCESS_INFORMATION*}. | - |
| 2333 | | - |
| 2334 | \sa QProcess::pid() | - |
| 2335 | */ | - |
| 2336 | | - |
| 2337 | QT_END_NAMESPACE | - |
| 2338 | | - |
| 2339 | #include "moc_qprocess.cpp" | - |
| 2340 | | - |
| 2341 | #endif // QT_NO_PROCESS | - |
| 2342 | | - |
| 2343 | | - |
| | |