| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | | - |
| 5 | | - |
| 6 | | - |
| 7 | | - |
| 8 | | - |
| 9 | | - |
| 10 | | - |
| 11 | | - |
| 12 | static const int errorBufferMax = 512; | - |
| 13 | | - |
| 14 | static int qt_qprocess_deadChild_pipe[2]; | - |
| 15 | static struct sigaction qt_sa_old_sigchld_handler; | - |
| 16 | static void qt_sa_sigchld_handler(int signum) | - |
| 17 | { | - |
| 18 | qt_safe_write(qt_qprocess_deadChild_pipe[1], "", 1); | - |
| 19 | | - |
| 20 | | - |
| 21 | | - |
| 22 | | - |
| 23 | | - |
| 24 | void (*oldAction)(int) = ((volatile struct sigaction *)&qt_sa_old_sigchld_handler)->__sigaction_handler.sa_handler; | - |
| 25 | if (oldAction && oldAction != ((__sighandler_t) 1)) partially evaluated: oldAction| no Evaluation Count:0 | yes Evaluation Count:2778 |
never evaluated: oldAction != ((__sighandler_t) 1) | 0-2778 |
| 26 | oldAction(signum); never executed: oldAction(signum); | 0 |
| 27 | } executed: }Execution Count:2778 | 2778 |
| 28 | | - |
| 29 | static inline void add_fd(int &nfds, int fd, fd_set *fdset) | - |
| 30 | { | - |
| 31 | (((fdset)->fds_bits)[((fd) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((fd) % (8 * (int) sizeof (__fd_mask))))); | - |
| 32 | if ((fd) > nfds) evaluated: (fd) > nfds| yes Evaluation Count:144488 | yes Evaluation Count:3813 |
| 3813-144488 |
| 33 | nfds = fd; executed: nfds = fd;Execution Count:144488 | 144488 |
| 34 | } executed: }Execution Count:148301 | 148301 |
| 35 | | - |
| 36 | struct QProcessInfo { | - |
| 37 | QProcess *process; | - |
| 38 | int deathPipe; | - |
| 39 | int exitResult; | - |
| 40 | pid_t pid; | - |
| 41 | int serialNumber; | - |
| 42 | }; | - |
| 43 | | - |
| 44 | class QProcessManager : public QThread | - |
| 45 | { | - |
| 46 | public: template <typename T> inline void qt_check_for_QOBJECT_macro(const T &_q_argument) const { int i = qYouForgotTheQ_OBJECT_Macro(this, &_q_argument); i = i + 1; } static const QMetaObject staticMetaObject; virtual const QMetaObject *metaObject() const; virtual void *qt_metacast(const char *); static inline QString tr(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } __attribute__ ((__deprecated__)) static inline QString trUtf8(const char *s, const char *c = 0, int n = -1) { return staticMetaObject.tr(s, c, n); } virtual int qt_metacall(QMetaObject::Call, int, void **); private: __attribute__((visibility("hidden"))) static void qt_static_metacall(QObject *, QMetaObject::Call, int, void **); struct QPrivateSignal {}; | - |
| 47 | public: | - |
| 48 | QProcessManager(); | - |
| 49 | ~QProcessManager(); | - |
| 50 | | - |
| 51 | void run(); | - |
| 52 | void catchDeadChildren(); | - |
| 53 | void add(pid_t pid, QProcess *process); | - |
| 54 | void remove(QProcess *process); | - |
| 55 | void lock(); | - |
| 56 | void unlock(); | - |
| 57 | | - |
| 58 | private: | - |
| 59 | QMutex mutex; | - |
| 60 | QHash<int, QProcessInfo *> children; | - |
| 61 | }; | - |
| 62 | | - |
| 63 | | - |
| 64 | static QProcessManager *processManagerInstance = 0; | - |
| 65 | | - |
| 66 | static QProcessManager *processManager() | - |
| 67 | { | - |
| 68 | | - |
| 69 | | - |
| 70 | static QBasicMutex processManagerGlobalMutex; | - |
| 71 | QMutexLocker locker(&processManagerGlobalMutex); | - |
| 72 | | - |
| 73 | if (!processManagerInstance) evaluated: !processManagerInstance| yes Evaluation Count:7 | yes Evaluation Count:16159 |
| 7-16159 |
| 74 | new QProcessManager; executed: new QProcessManager;Execution Count:7 | 7 |
| 75 | | - |
| 76 | qt_noop(); | - |
| 77 | return processManagerInstance; executed: return processManagerInstance;Execution Count:16166 | 16166 |
| 78 | } | - |
| 79 | | - |
| 80 | QProcessManager::QProcessManager() | - |
| 81 | { | - |
| 82 | | - |
| 83 | | - |
| 84 | | - |
| 85 | | - |
| 86 | | - |
| 87 | | - |
| 88 | qt_safe_pipe(qt_qprocess_deadChild_pipe, 04000); | - |
| 89 | | - |
| 90 | | - |
| 91 | | - |
| 92 | struct sigaction action; | - |
| 93 | memset(&action, 0, sizeof(action)); | - |
| 94 | action.__sigaction_handler.sa_handler = qt_sa_sigchld_handler; | - |
| 95 | action.sa_flags = 1; | - |
| 96 | ::sigaction(17, &action, &qt_sa_old_sigchld_handler); | - |
| 97 | | - |
| 98 | processManagerInstance = this; | - |
| 99 | } executed: }Execution Count:7 | 7 |
| 100 | | - |
| 101 | QProcessManager::~QProcessManager() | - |
| 102 | { | - |
| 103 | | - |
| 104 | qt_safe_write(qt_qprocess_deadChild_pipe[1], "@", 1); | - |
| 105 | qt_safe_close(qt_qprocess_deadChild_pipe[1]); | - |
| 106 | wait(); | - |
| 107 | | - |
| 108 | | - |
| 109 | | - |
| 110 | qt_safe_close(qt_qprocess_deadChild_pipe[0]); | - |
| 111 | | - |
| 112 | qt_qprocess_deadChild_pipe[0] = -1; | - |
| 113 | qt_qprocess_deadChild_pipe[1] = -1; | - |
| 114 | | - |
| 115 | qDeleteAll(children.values()); | - |
| 116 | children.clear(); | - |
| 117 | | - |
| 118 | struct sigaction currentAction; | - |
| 119 | ::sigaction(17, 0, ¤tAction); | - |
| 120 | if (currentAction.__sigaction_handler.sa_handler == qt_sa_sigchld_handler) { never evaluated: currentAction.__sigaction_handler.sa_handler == qt_sa_sigchld_handler | 0 |
| 121 | ::sigaction(17, &qt_sa_old_sigchld_handler, 0); | - |
| 122 | } | 0 |
| 123 | | - |
| 124 | processManagerInstance = 0; | - |
| 125 | } | 0 |
| 126 | | - |
| 127 | void QProcessManager::run() | - |
| 128 | { | - |
| 129 | for(;;) { | - |
| 130 | fd_set readset; | - |
| 131 | do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&readset)->fds_bits)[0]) : "memory"); } while (0); partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:2549 |
executed: }Execution Count:2549 | 0-2549 |
| 132 | (((&readset)->fds_bits)[((qt_qprocess_deadChild_pipe[0]) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((qt_qprocess_deadChild_pipe[0]) % (8 * (int) sizeof (__fd_mask))))); | - |
| 133 | int nselect = select(qt_qprocess_deadChild_pipe[0] + 1, &readset, 0, 0, 0); | - |
| 134 | if (nselect < 0) { evaluated: nselect < 0| yes Evaluation Count:1 | yes Evaluation Count:2517 |
| 1-2517 |
| 135 | if ((*__errno_location ()) == 4) partially evaluated: (*__errno_location ()) == 4| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 136 | continue; executed: continue;Execution Count:1 | 1 |
| 137 | break; | 0 |
| 138 | } | - |
| 139 | | - |
| 140 | | - |
| 141 | | - |
| 142 | | - |
| 143 | char c; | - |
| 144 | if (qt_safe_read(qt_qprocess_deadChild_pipe[0], &c, 1) < 0 || c == '@') partially evaluated: qt_safe_read(qt_qprocess_deadChild_pipe[0], &c, 1) < 0| no Evaluation Count:0 | yes Evaluation Count:2517 |
partially evaluated: c == '@'| no Evaluation Count:0 | yes Evaluation Count:2517 |
| 0-2517 |
| 145 | break; | 0 |
| 146 | | - |
| 147 | | - |
| 148 | catchDeadChildren(); | - |
| 149 | } executed: }Execution Count:2517 | 2517 |
| 150 | } | 0 |
| 151 | | - |
| 152 | void QProcessManager::catchDeadChildren() | - |
| 153 | { | - |
| 154 | QMutexLocker locker(&mutex); | - |
| 155 | | - |
| 156 | | - |
| 157 | | - |
| 158 | QHash<int, QProcessInfo *>::Iterator it = children.begin(); | - |
| 159 | while (it != children.end()) { evaluated: it != children.end()| yes Evaluation Count:3193 | yes Evaluation Count:2517 |
| 2517-3193 |
| 160 | | - |
| 161 | | - |
| 162 | QProcessInfo *info = it.value(); | - |
| 163 | qt_safe_write(info->deathPipe, "", 1); | - |
| 164 | | - |
| 165 | | - |
| 166 | | - |
| 167 | | - |
| 168 | ++it; | - |
| 169 | } executed: }Execution Count:3193 | 3193 |
| 170 | } executed: }Execution Count:2517 | 2517 |
| 171 | | - |
| 172 | static QBasicAtomicInt idCounter = { (1) }; | - |
| 173 | | - |
| 174 | void QProcessManager::add(pid_t pid, QProcess *process) | - |
| 175 | { | - |
| 176 | | - |
| 177 | | - |
| 178 | | - |
| 179 | | - |
| 180 | | - |
| 181 | QProcessInfo *info = new QProcessInfo; | - |
| 182 | info->process = process; | - |
| 183 | info->deathPipe = process->d_func()->deathPipe[1]; | - |
| 184 | info->exitResult = 0; | - |
| 185 | info->pid = pid; | - |
| 186 | | - |
| 187 | int serial = idCounter.fetchAndAddRelaxed(1); | - |
| 188 | process->d_func()->serial = serial; | - |
| 189 | children.insert(serial, info); | - |
| 190 | } executed: }Execution Count:2520 | 2520 |
| 191 | | - |
| 192 | void QProcessManager::remove(QProcess *process) | - |
| 193 | { | - |
| 194 | QMutexLocker locker(&mutex); | - |
| 195 | | - |
| 196 | int serial = process->d_func()->serial; | - |
| 197 | QProcessInfo *info = children.take(serial); | - |
| 198 | | - |
| 199 | | - |
| 200 | | - |
| 201 | | - |
| 202 | delete info; | - |
| 203 | } executed: }Execution Count:5937 | 5937 |
| 204 | | - |
| 205 | void QProcessManager::lock() | - |
| 206 | { | - |
| 207 | mutex.lock(); | - |
| 208 | } executed: }Execution Count:2520 | 2520 |
| 209 | | - |
| 210 | void QProcessManager::unlock() | - |
| 211 | { | - |
| 212 | mutex.unlock(); | - |
| 213 | } executed: }Execution Count:2520 | 2520 |
| 214 | | - |
| 215 | static void qt_create_pipe(int *pipe) | - |
| 216 | { | - |
| 217 | if (pipe[0] != -1) partially evaluated: pipe[0] != -1| no Evaluation Count:0 | yes Evaluation Count:12580 |
| 0-12580 |
| 218 | qt_safe_close(pipe[0]); never executed: qt_safe_close(pipe[0]); | 0 |
| 219 | if (pipe[1] != -1) partially evaluated: pipe[1] != -1| no Evaluation Count:0 | yes Evaluation Count:12580 |
| 0-12580 |
| 220 | qt_safe_close(pipe[1]); never executed: qt_safe_close(pipe[1]); | 0 |
| 221 | if (qt_safe_pipe(pipe) != 0) { partially evaluated: qt_safe_pipe(pipe) != 0| no Evaluation Count:0 | yes Evaluation Count:12580 |
| 0-12580 |
| 222 | QMessageLogger("io/qprocess_unix.cpp", 338, __PRETTY_FUNCTION__).warning("QProcessPrivate::createPipe: Cannot create pipe %p: %s", | - |
| 223 | pipe, QString(qt_error_string((*__errno_location ()))).toLocal8Bit().constData()); | - |
| 224 | } | 0 |
| 225 | } executed: }Execution Count:12580 | 12580 |
| 226 | | - |
| 227 | void QProcessPrivate::destroyPipe(int *pipe) | - |
| 228 | { | - |
| 229 | if (pipe[1] != -1) { evaluated: pipe[1] != -1| yes Evaluation Count:5037 | yes Evaluation Count:23105 |
| 5037-23105 |
| 230 | qt_safe_close(pipe[1]); | - |
| 231 | pipe[1] = -1; | - |
| 232 | } executed: }Execution Count:5037 | 5037 |
| 233 | if (pipe[0] != -1) { evaluated: pipe[0] != -1| yes Evaluation Count:7541 | yes Evaluation Count:20601 |
| 7541-20601 |
| 234 | qt_safe_close(pipe[0]); | - |
| 235 | pipe[0] = -1; | - |
| 236 | } executed: }Execution Count:7541 | 7541 |
| 237 | } executed: }Execution Count:28142 | 28142 |
| 238 | | - |
| 239 | void QProcessPrivate::destroyChannel(Channel *channel) | - |
| 240 | { | - |
| 241 | destroyPipe(channel->pipe); | - |
| 242 | } executed: }Execution Count:19654 | 19654 |
| 243 | | - |
| 244 | | - |
| 245 | | - |
| 246 | | - |
| 247 | | - |
| 248 | | - |
| 249 | bool QProcessPrivate::createChannel(Channel &channel) | - |
| 250 | { | - |
| 251 | QProcess * const q = q_func(); | - |
| 252 | | - |
| 253 | if (&channel == &stderrChannel && processChannelMode == QProcess::MergedChannels) { evaluated: &channel == &stderrChannel| yes Evaluation Count:2520 | yes Evaluation Count:5040 |
evaluated: processChannelMode == QProcess::MergedChannels| yes Evaluation Count:11 | yes Evaluation Count:2509 |
| 11-5040 |
| 254 | channel.pipe[0] = -1; | - |
| 255 | channel.pipe[1] = -1; | - |
| 256 | return true; executed: return true;Execution Count:11 | 11 |
| 257 | } | - |
| 258 | | - |
| 259 | if (channel.type == Channel::Normal) { evaluated: channel.type == Channel::Normal| yes Evaluation Count:7538 | yes Evaluation Count:11 |
| 11-7538 |
| 260 | | - |
| 261 | qt_create_pipe(channel.pipe); | - |
| 262 | | - |
| 263 | | - |
| 264 | if (threadData->eventDispatcher) { evaluated: threadData->eventDispatcher| yes Evaluation Count:7295 | yes Evaluation Count:243 |
| 243-7295 |
| 265 | if (&channel == &stdinChannel) { evaluated: &channel == &stdinChannel| yes Evaluation Count:2436 | yes Evaluation Count:4859 |
| 2436-4859 |
| 266 | channel.notifier = new QSocketNotifier(channel.pipe[1], | - |
| 267 | QSocketNotifier::Write, q); | - |
| 268 | channel.notifier->setEnabled(false); | - |
| 269 | QObject::connect(channel.notifier, "2""activated(int)", | - |
| 270 | q, "1""_q_canWrite()"); | - |
| 271 | } else { executed: }Execution Count:2436 | 2436 |
| 272 | channel.notifier = new QSocketNotifier(channel.pipe[0], | - |
| 273 | QSocketNotifier::Read, q); | - |
| 274 | const char *receiver; | - |
| 275 | if (&channel == &stdoutChannel) evaluated: &channel == &stdoutChannel| yes Evaluation Count:2433 | yes Evaluation Count:2426 |
| 2426-2433 |
| 276 | receiver = "1""_q_canReadStandardOutput()"; executed: receiver = "1""_q_canReadStandardOutput()";Execution Count:2433 | 2433 |
| 277 | else | - |
| 278 | receiver = "1""_q_canReadStandardError()"; executed: receiver = "1""_q_canReadStandardError()";Execution Count:2426 | 2426 |
| 279 | QObject::connect(channel.notifier, "2""activated(int)", | - |
| 280 | q, receiver); | - |
| 281 | } executed: }Execution Count:4859 | 4859 |
| 282 | } | - |
| 283 | | - |
| 284 | return true; executed: return true;Execution Count:7538 | 7538 |
| 285 | } else if (channel.type == Channel::Redirect) { evaluated: channel.type == Channel::Redirect| yes Evaluation Count:7 | yes Evaluation Count:4 |
| 4-7 |
| 286 | | - |
| 287 | QByteArray fname = QFile::encodeName(channel.file); | - |
| 288 | | - |
| 289 | if (&channel == &stdinChannel) { evaluated: &channel == &stdinChannel| yes Evaluation Count:1 | yes Evaluation Count:6 |
| 1-6 |
| 290 | | - |
| 291 | channel.pipe[1] = -1; | - |
| 292 | if ( (channel.pipe[0] = qt_safe_open(fname, 00)) != -1) partially evaluated: (channel.pipe[0] = qt_safe_open(fname, 00)) != -1| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 293 | return true; executed: return true;Execution Count:1 | 1 |
| 294 | | - |
| 295 | q->setErrorString(QProcess::tr("Could not open input redirection for reading")); | - |
| 296 | } else { | 0 |
| 297 | int mode = 01 | 0100; | - |
| 298 | if (channel.append) evaluated: channel.append| yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
| 299 | mode |= 02000; executed: mode |= 02000;Execution Count:3 | 3 |
| 300 | else | - |
| 301 | mode |= 01000; executed: mode |= 01000;Execution Count:3 | 3 |
| 302 | | - |
| 303 | channel.pipe[0] = -1; | - |
| 304 | if ( (channel.pipe[1] = qt_safe_open(fname, mode, 0666)) != -1) partially evaluated: (channel.pipe[1] = qt_safe_open(fname, mode, 0666)) != -1| yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
| 305 | return true; executed: return true;Execution Count:6 | 6 |
| 306 | | - |
| 307 | q->setErrorString(QProcess::tr("Could not open output redirection for writing")); | - |
| 308 | } | 0 |
| 309 | | - |
| 310 | | - |
| 311 | processError = QProcess::FailedToStart; | - |
| 312 | q->error(processError); | - |
| 313 | cleanup(); | - |
| 314 | return false; never executed: return false; | 0 |
| 315 | } else { | - |
| 316 | qt_noop(); | - |
| 317 | | - |
| 318 | Channel *source; | - |
| 319 | Channel *sink; | - |
| 320 | | - |
| 321 | if (channel.type == Channel::PipeSource) { evaluated: channel.type == Channel::PipeSource| yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
| 322 | | - |
| 323 | source = &channel; | - |
| 324 | sink = &channel.process->stdinChannel; | - |
| 325 | | - |
| 326 | qt_noop(); | - |
| 327 | qt_noop(); | - |
| 328 | } else { executed: }Execution Count:2 | 2 |
| 329 | | - |
| 330 | source = &channel.process->stdoutChannel; | - |
| 331 | sink = &channel; | - |
| 332 | | - |
| 333 | qt_noop(); | - |
| 334 | qt_noop(); | - |
| 335 | } executed: }Execution Count:2 | 2 |
| 336 | | - |
| 337 | if (source->pipe[1] != -1 || sink->pipe[0] != -1) { partially evaluated: source->pipe[1] != -1| no Evaluation Count:0 | yes Evaluation Count:4 |
evaluated: sink->pipe[0] != -1| yes Evaluation Count:2 | yes Evaluation Count:2 |
| 0-4 |
| 338 | | - |
| 339 | return true; executed: return true;Execution Count:2 | 2 |
| 340 | } else { | - |
| 341 | qt_noop(); | - |
| 342 | qt_noop(); | - |
| 343 | | - |
| 344 | Q_PIPE pipe[2] = { -1, -1 }; | - |
| 345 | qt_create_pipe(pipe); | - |
| 346 | sink->pipe[0] = pipe[0]; | - |
| 347 | source->pipe[1] = pipe[1]; | - |
| 348 | | - |
| 349 | return true; executed: return true;Execution Count:2 | 2 |
| 350 | } | - |
| 351 | } | - |
| 352 | } | - |
| 353 | | - |
| 354 | | - |
| 355 | | - |
| 356 | | - |
| 357 | | - |
| 358 | | - |
| 359 | extern char **environ; | - |
| 360 | | - |
| 361 | | - |
| 362 | | - |
| 363 | QProcessEnvironment QProcessEnvironment::systemEnvironment() | - |
| 364 | { | - |
| 365 | QProcessEnvironment env; | - |
| 366 | | - |
| 367 | const char *entry; | - |
| 368 | for (int count = 0; (entry = environ[count]); ++count) { evaluated: (entry = environ[count])| yes Evaluation Count:313 | yes Evaluation Count:14 |
| 14-313 |
| 369 | const char *equal = strchr(entry, '='); | - |
| 370 | if (!equal) partially evaluated: !equal| no Evaluation Count:0 | yes Evaluation Count:313 |
| 0-313 |
| 371 | continue; never executed: continue; | 0 |
| 372 | | - |
| 373 | QByteArray name(entry, equal - entry); | - |
| 374 | QByteArray value(equal + 1); | - |
| 375 | env.d->hash.insert(QProcessEnvironmentPrivate::Key(name), | - |
| 376 | QProcessEnvironmentPrivate::Value(value)); | - |
| 377 | } executed: }Execution Count:313 | 313 |
| 378 | | - |
| 379 | return env; executed: return env;Execution Count:14 | 14 |
| 380 | } | - |
| 381 | | - |
| 382 | static char **_q_dupEnvironment(const QProcessEnvironmentPrivate::Hash &environment, int *envc) | - |
| 383 | { | - |
| 384 | *envc = 0; | - |
| 385 | if (environment.isEmpty()) partially evaluated: environment.isEmpty()| no Evaluation Count:0 | yes Evaluation Count:871 |
| 0-871 |
| 386 | return 0; never executed: return 0; | 0 |
| 387 | | - |
| 388 | | - |
| 389 | | - |
| 390 | | - |
| 391 | | - |
| 392 | | - |
| 393 | | - |
| 394 | static const char libraryPath[] = "LD_LIBRARY_PATH"; | - |
| 395 | | - |
| 396 | const QByteArray envLibraryPath = qgetenv(libraryPath); | - |
| 397 | bool needToAddLibraryPath = !envLibraryPath.isEmpty() && evaluated: !envLibraryPath.isEmpty()| yes Evaluation Count:173 | yes Evaluation Count:698 |
| 173-698 |
| 398 | !environment.contains(QProcessEnvironmentPrivate::Key(QByteArray(libraryPath))); partially evaluated: !environment.contains(QProcessEnvironmentPrivate::Key(QByteArray(libraryPath)))| no Evaluation Count:0 | yes Evaluation Count:173 |
| 0-173 |
| 399 | | - |
| 400 | char **envp = new char *[environment.count() + 2]; | - |
| 401 | envp[environment.count()] = 0; | - |
| 402 | envp[environment.count() + 1] = 0; | - |
| 403 | | - |
| 404 | QProcessEnvironmentPrivate::Hash::ConstIterator it = environment.constBegin(); | - |
| 405 | const QProcessEnvironmentPrivate::Hash::ConstIterator end = environment.constEnd(); | - |
| 406 | for ( ; it != end; ++it) { evaluated: it != end| yes Evaluation Count:7129 | yes Evaluation Count:871 |
| 871-7129 |
| 407 | QByteArray key = it.key().key; | - |
| 408 | QByteArray value = it.value().bytes(); | - |
| 409 | key.reserve(key.length() + 1 + value.length()); | - |
| 410 | key.append('='); | - |
| 411 | key.append(value); | - |
| 412 | | - |
| 413 | envp[(*envc)++] = ::strdup(key.constData()); | - |
| 414 | } executed: }Execution Count:7129 | 7129 |
| 415 | | - |
| 416 | if (needToAddLibraryPath) partially evaluated: needToAddLibraryPath| no Evaluation Count:0 | yes Evaluation Count:871 |
| 0-871 |
| 417 | envp[(*envc)++] = ::strdup(QByteArray(QByteArray(libraryPath) + '=' + | 0 |
| 418 | envLibraryPath).constData()); never executed: envp[(*envc)++] = ::strdup(QByteArray(QByteArray(libraryPath) + '=' + envLibraryPath).constData()); | 0 |
| 419 | return envp; executed: return envp;Execution Count:871 | 871 |
| 420 | } | - |
| 421 | | - |
| 422 | void QProcessPrivate::startProcess() | - |
| 423 | { | - |
| 424 | QProcess * const q = q_func(); | - |
| 425 | | - |
| 426 | | - |
| 427 | | - |
| 428 | | - |
| 429 | | - |
| 430 | processManager()->start(); | - |
| 431 | | - |
| 432 | | - |
| 433 | if (!createChannel(stdinChannel) || partially evaluated: !createChannel(stdinChannel)| no Evaluation Count:0 | yes Evaluation Count:2520 |
| 0-2520 |
| 434 | !createChannel(stdoutChannel) || partially evaluated: !createChannel(stdoutChannel)| no Evaluation Count:0 | yes Evaluation Count:2520 |
| 0-2520 |
| 435 | !createChannel(stderrChannel)) partially evaluated: !createChannel(stderrChannel)| no Evaluation Count:0 | yes Evaluation Count:2520 |
| 0-2520 |
| 436 | return; | 0 |
| 437 | qt_create_pipe(childStartedPipe); | - |
| 438 | qt_create_pipe(deathPipe); | - |
| 439 | | - |
| 440 | if (threadData->eventDispatcher) { evaluated: threadData->eventDispatcher| yes Evaluation Count:2439 | yes Evaluation Count:81 |
| 81-2439 |
| 441 | startupSocketNotifier = new QSocketNotifier(childStartedPipe[0], | - |
| 442 | QSocketNotifier::Read, q); | - |
| 443 | QObject::connect(startupSocketNotifier, "2""activated(int)", | - |
| 444 | q, "1""_q_startupNotification()"); | - |
| 445 | | - |
| 446 | deathNotifier = new QSocketNotifier(deathPipe[0], | - |
| 447 | QSocketNotifier::Read, q); | - |
| 448 | QObject::connect(deathNotifier, "2""activated(int)", | - |
| 449 | q, "1""_q_processDied()"); | - |
| 450 | } executed: }Execution Count:2439 | 2439 |
| 451 | | - |
| 452 | | - |
| 453 | q->setProcessState(QProcess::Starting); | - |
| 454 | | - |
| 455 | | - |
| 456 | | - |
| 457 | char **argv = new char *[arguments.count() + 2]; | - |
| 458 | argv[arguments.count() + 1] = 0; | - |
| 459 | | - |
| 460 | | - |
| 461 | QByteArray encodedProgramName = QFile::encodeName(program); | - |
| 462 | char *dupProgramName = ::strdup(encodedProgramName.constData()); | - |
| 463 | argv[0] = dupProgramName; | - |
| 464 | | - |
| 465 | | - |
| 466 | for (int i = 0; i < arguments.count(); ++i) evaluated: i < arguments.count()| yes Evaluation Count:3808 | yes Evaluation Count:2520 |
| 2520-3808 |
| 467 | argv[i + 1] = ::strdup(QFile::encodeName(arguments.at(i)).constData()); executed: argv[i + 1] = ::strdup(QFile::encodeName(arguments.at(i)).constData());Execution Count:3808 | 3808 |
| 468 | | - |
| 469 | | - |
| 470 | int envc = 0; | - |
| 471 | char **envp = 0; | - |
| 472 | if (environment.d.constData()) evaluated: environment.d.constData()| yes Evaluation Count:871 | yes Evaluation Count:1649 |
| 871-1649 |
| 473 | envp = _q_dupEnvironment(environment.d.constData()->hash, &envc); executed: envp = _q_dupEnvironment(environment.d.constData()->hash, &envc);Execution Count:871 | 871 |
| 474 | | - |
| 475 | | - |
| 476 | const char *workingDirPtr = 0; | - |
| 477 | QByteArray encodedWorkingDirectory; | - |
| 478 | if (!workingDirectory.isEmpty()) { evaluated: !workingDirectory.isEmpty()| yes Evaluation Count:204 | yes Evaluation Count:2316 |
| 204-2316 |
| 479 | encodedWorkingDirectory = QFile::encodeName(workingDirectory); | - |
| 480 | workingDirPtr = encodedWorkingDirectory.constData(); | - |
| 481 | } executed: }Execution Count:204 | 204 |
| 482 | | - |
| 483 | | - |
| 484 | | - |
| 485 | char **path = 0; | - |
| 486 | int pathc = 0; | - |
| 487 | if (!program.contains(QLatin1Char('/'))) { evaluated: !program.contains(QLatin1Char('/'))| yes Evaluation Count:379 | yes Evaluation Count:2141 |
| 379-2141 |
| 488 | const QString pathEnv = QString::fromLocal8Bit(::getenv("PATH")); | - |
| 489 | if (!pathEnv.isEmpty()) { partially evaluated: !pathEnv.isEmpty()| yes Evaluation Count:379 | no Evaluation Count:0 |
| 0-379 |
| 490 | QStringList pathEntries = pathEnv.split(QLatin1Char(':'), QString::SkipEmptyParts); | - |
| 491 | if (!pathEntries.isEmpty()) { partially evaluated: !pathEntries.isEmpty()| yes Evaluation Count:379 | no Evaluation Count:0 |
| 0-379 |
| 492 | pathc = pathEntries.size(); | - |
| 493 | path = new char *[pathc + 1]; | - |
| 494 | path[pathc] = 0; | - |
| 495 | | - |
| 496 | for (int k = 0; k < pathEntries.size(); ++k) { evaluated: k < pathEntries.size()| yes Evaluation Count:4927 | yes Evaluation Count:379 |
| 379-4927 |
| 497 | QByteArray tmp = QFile::encodeName(pathEntries.at(k)); | - |
| 498 | if (!tmp.endsWith('/')) tmp += '/'; partially evaluated: !tmp.endsWith('/')| yes Evaluation Count:4927 | no Evaluation Count:0 |
executed: tmp += '/';Execution Count:4927 | 0-4927 |
| 499 | tmp += encodedProgramName; | - |
| 500 | path[k] = ::strdup(tmp.constData()); | - |
| 501 | } executed: }Execution Count:4927 | 4927 |
| 502 | } executed: }Execution Count:379 | 379 |
| 503 | } executed: }Execution Count:379 | 379 |
| 504 | } executed: }Execution Count:379 | 379 |
| 505 | | - |
| 506 | | - |
| 507 | processManager()->lock(); | - |
| 508 | | - |
| 509 | | - |
| 510 | | - |
| 511 | pid_t childPid = fork(); | - |
| 512 | int lastForkErrno = (*__errno_location ()); | - |
| 513 | | - |
| 514 | if (childPid != 0) { partially evaluated: childPid != 0| yes Evaluation Count:2520 | no Evaluation Count:0 |
| 0-2520 |
| 515 | | - |
| 516 | free(dupProgramName); | - |
| 517 | for (int i = 1; i <= arguments.count(); ++i) evaluated: i <= arguments.count()| yes Evaluation Count:3808 | yes Evaluation Count:2520 |
| 2520-3808 |
| 518 | free(argv[i]); executed: free(argv[i]);Execution Count:3808 | 3808 |
| 519 | for (int i = 0; i < envc; ++i) evaluated: i < envc| yes Evaluation Count:7129 | yes Evaluation Count:2520 |
| 2520-7129 |
| 520 | free(envp[i]); executed: free(envp[i]);Execution Count:7129 | 7129 |
| 521 | for (int i = 0; i < pathc; ++i) evaluated: i < pathc| yes Evaluation Count:4927 | yes Evaluation Count:2520 |
| 2520-4927 |
| 522 | free(path[i]); executed: free(path[i]);Execution Count:4927 | 4927 |
| 523 | delete [] argv; | - |
| 524 | delete [] envp; | - |
| 525 | delete [] path; | - |
| 526 | } executed: }Execution Count:2520 | 2520 |
| 527 | if (childPid < 0) { partially evaluated: childPid < 0| no Evaluation Count:0 | yes Evaluation Count:2520 |
| 0-2520 |
| 528 | | - |
| 529 | | - |
| 530 | | - |
| 531 | | - |
| 532 | processManager()->unlock(); | - |
| 533 | q->setProcessState(QProcess::NotRunning); | - |
| 534 | processError = QProcess::FailedToStart; | - |
| 535 | q->setErrorString(QProcess::tr("Resource error (fork failure): %1").arg(qt_error_string(lastForkErrno))); | - |
| 536 | q->error(processError); | - |
| 537 | cleanup(); | - |
| 538 | return; | 0 |
| 539 | } | - |
| 540 | | - |
| 541 | | - |
| 542 | if (childPid == 0) { partially evaluated: childPid == 0| no Evaluation Count:0 | yes Evaluation Count:2520 |
| 0-2520 |
| 543 | execChild(workingDirPtr, path, argv, envp); | - |
| 544 | ::_exit(-1); | - |
| 545 | } | 0 |
| 546 | | - |
| 547 | | - |
| 548 | | - |
| 549 | | - |
| 550 | processManager()->add(childPid, q); | - |
| 551 | pid = Q_PID(childPid); | - |
| 552 | processManager()->unlock(); | - |
| 553 | | - |
| 554 | | - |
| 555 | | - |
| 556 | ::fcntl(deathPipe[0], 4, ::fcntl(deathPipe[0], 3) | 04000); | - |
| 557 | qt_safe_close(childStartedPipe[1]); | - |
| 558 | childStartedPipe[1] = -1; | - |
| 559 | | - |
| 560 | if (stdinChannel.pipe[0] != -1) { partially evaluated: stdinChannel.pipe[0] != -1| yes Evaluation Count:2520 | no Evaluation Count:0 |
| 0-2520 |
| 561 | qt_safe_close(stdinChannel.pipe[0]); | - |
| 562 | stdinChannel.pipe[0] = -1; | - |
| 563 | } executed: }Execution Count:2520 | 2520 |
| 564 | | - |
| 565 | if (stdinChannel.pipe[1] != -1) evaluated: stdinChannel.pipe[1] != -1| yes Evaluation Count:2517 | yes Evaluation Count:3 |
| 3-2517 |
| 566 | ::fcntl(stdinChannel.pipe[1], 4, ::fcntl(stdinChannel.pipe[1], 3) | 04000); executed: ::fcntl(stdinChannel.pipe[1], 4, ::fcntl(stdinChannel.pipe[1], 3) | 04000);Execution Count:2517 | 2517 |
| 567 | | - |
| 568 | if (stdoutChannel.pipe[1] != -1) { partially evaluated: stdoutChannel.pipe[1] != -1| yes Evaluation Count:2520 | no Evaluation Count:0 |
| 0-2520 |
| 569 | qt_safe_close(stdoutChannel.pipe[1]); | - |
| 570 | stdoutChannel.pipe[1] = -1; | - |
| 571 | } executed: }Execution Count:2520 | 2520 |
| 572 | | - |
| 573 | if (stdoutChannel.pipe[0] != -1) evaluated: stdoutChannel.pipe[0] != -1| yes Evaluation Count:2514 | yes Evaluation Count:6 |
| 6-2514 |
| 574 | ::fcntl(stdoutChannel.pipe[0], 4, ::fcntl(stdoutChannel.pipe[0], 3) | 04000); executed: ::fcntl(stdoutChannel.pipe[0], 4, ::fcntl(stdoutChannel.pipe[0], 3) | 04000);Execution Count:2514 | 2514 |
| 575 | | - |
| 576 | if (stderrChannel.pipe[1] != -1) { evaluated: stderrChannel.pipe[1] != -1| yes Evaluation Count:2509 | yes Evaluation Count:11 |
| 11-2509 |
| 577 | qt_safe_close(stderrChannel.pipe[1]); | - |
| 578 | stderrChannel.pipe[1] = -1; | - |
| 579 | } executed: }Execution Count:2509 | 2509 |
| 580 | if (stderrChannel.pipe[0] != -1) evaluated: stderrChannel.pipe[0] != -1| yes Evaluation Count:2507 | yes Evaluation Count:13 |
| 13-2507 |
| 581 | ::fcntl(stderrChannel.pipe[0], 4, ::fcntl(stderrChannel.pipe[0], 3) | 04000); executed: ::fcntl(stderrChannel.pipe[0], 4, ::fcntl(stderrChannel.pipe[0], 3) | 04000);Execution Count:2507 | 2507 |
| 582 | } executed: }Execution Count:2520 | 2520 |
| 583 | void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv, char **envp) | - |
| 584 | { | - |
| 585 | ::signal(13, ((__sighandler_t) 0)); | - |
| 586 | | - |
| 587 | QProcess * const q = q_func(); | - |
| 588 | | - |
| 589 | | - |
| 590 | qt_safe_dup2(stdinChannel.pipe[0], fileno(stdin), 0); | - |
| 591 | | - |
| 592 | | - |
| 593 | if (processChannelMode != QProcess::ForwardedChannels) { never evaluated: processChannelMode != QProcess::ForwardedChannels | 0 |
| 594 | qt_safe_dup2(stdoutChannel.pipe[1], fileno(stdout), 0); | - |
| 595 | | - |
| 596 | | - |
| 597 | if (processChannelMode == QProcess::MergedChannels) { never evaluated: processChannelMode == QProcess::MergedChannels | 0 |
| 598 | qt_safe_dup2(fileno(stdout), fileno(stderr), 0); | - |
| 599 | } else { | 0 |
| 600 | qt_safe_dup2(stderrChannel.pipe[1], fileno(stderr), 0); | - |
| 601 | } | 0 |
| 602 | } | - |
| 603 | | - |
| 604 | | - |
| 605 | qt_safe_close(childStartedPipe[0]); | - |
| 606 | | - |
| 607 | | - |
| 608 | if (workingDir) { never evaluated: workingDir | 0 |
| 609 | if (::chdir(workingDir) == -1) never evaluated: ::chdir(workingDir) == -1 | 0 |
| 610 | QMessageLogger("io/qprocess_unix.cpp", 858, __PRETTY_FUNCTION__).warning("QProcessPrivate::execChild() failed to chdir to %s", workingDir); never executed: QMessageLogger("io/qprocess_unix.cpp", 858, __PRETTY_FUNCTION__).warning("QProcessPrivate::execChild() failed to chdir to %s", workingDir); | 0 |
| 611 | } | 0 |
| 612 | | - |
| 613 | | - |
| 614 | q->setupChildProcess(); | - |
| 615 | | - |
| 616 | | - |
| 617 | if (!envp) { | 0 |
| 618 | qt_safe_execvp(argv[0], argv); | - |
| 619 | } else { | 0 |
| 620 | if (path) { | 0 |
| 621 | char **arg = path; | - |
| 622 | while (*arg) { | 0 |
| 623 | argv[0] = *arg; | - |
| 624 | | - |
| 625 | | - |
| 626 | | - |
| 627 | qt_safe_execve(argv[0], argv, envp); | - |
| 628 | ++arg; | - |
| 629 | } | 0 |
| 630 | } else { | 0 |
| 631 | | - |
| 632 | | - |
| 633 | | - |
| 634 | qt_safe_execve(argv[0], argv, envp); | - |
| 635 | } | 0 |
| 636 | } | - |
| 637 | | - |
| 638 | | - |
| 639 | QString error = qt_error_string((*__errno_location ())); | - |
| 640 | | - |
| 641 | | - |
| 642 | | - |
| 643 | qt_safe_write(childStartedPipe[1], error.data(), error.length() * sizeof(QChar)); | - |
| 644 | qt_safe_close(childStartedPipe[1]); | - |
| 645 | childStartedPipe[1] = -1; | - |
| 646 | } | 0 |
| 647 | | - |
| 648 | | - |
| 649 | bool QProcessPrivate::processStarted() | - |
| 650 | { | - |
| 651 | ushort buf[errorBufferMax]; | - |
| 652 | int i = qt_safe_read(childStartedPipe[0], &buf, sizeof buf); | - |
| 653 | if (startupSocketNotifier) { evaluated: startupSocketNotifier| yes Evaluation Count:2439 | yes Evaluation Count:81 |
| 81-2439 |
| 654 | startupSocketNotifier->setEnabled(false); | - |
| 655 | startupSocketNotifier->deleteLater(); | - |
| 656 | startupSocketNotifier = 0; | - |
| 657 | } executed: }Execution Count:2439 | 2439 |
| 658 | qt_safe_close(childStartedPipe[0]); | - |
| 659 | childStartedPipe[0] = -1; | - |
| 660 | | - |
| 661 | | - |
| 662 | | - |
| 663 | | - |
| 664 | | - |
| 665 | | - |
| 666 | if (i > 0) evaluated: i > 0| yes Evaluation Count:827 | yes Evaluation Count:1693 |
| 827-1693 |
| 667 | q_func()->setErrorString(QString((const QChar *)buf, i / sizeof(QChar))); executed: q_func()->setErrorString(QString((const QChar *)buf, i / sizeof(QChar)));Execution Count:827 | 827 |
| 668 | | - |
| 669 | return i <= 0; executed: return i <= 0;Execution Count:2520 | 2520 |
| 670 | } | - |
| 671 | | - |
| 672 | qint64 QProcessPrivate::bytesAvailableFromStdout() const | - |
| 673 | { | - |
| 674 | int nbytes = 0; | - |
| 675 | qint64 available = 0; | - |
| 676 | if (::ioctl(stdoutChannel.pipe[0], 0x541B, (char *) &nbytes) >= 0) evaluated: ::ioctl(stdoutChannel.pipe[0], 0x541B, (char *) &nbytes) >= 0| yes Evaluation Count:47993 | yes Evaluation Count:1662 |
| 1662-47993 |
| 677 | available = (qint64) nbytes; executed: available = (qint64) nbytes;Execution Count:47993 | 47993 |
| 678 | | - |
| 679 | | - |
| 680 | | - |
| 681 | return available; executed: return available;Execution Count:49655 | 49655 |
| 682 | } | - |
| 683 | | - |
| 684 | qint64 QProcessPrivate::bytesAvailableFromStderr() const | - |
| 685 | { | - |
| 686 | int nbytes = 0; | - |
| 687 | qint64 available = 0; | - |
| 688 | if (::ioctl(stderrChannel.pipe[0], 0x541B, (char *) &nbytes) >= 0) evaluated: ::ioctl(stderrChannel.pipe[0], 0x541B, (char *) &nbytes) >= 0| yes Evaluation Count:2039 | yes Evaluation Count:1691 |
| 1691-2039 |
| 689 | available = (qint64) nbytes; executed: available = (qint64) nbytes;Execution Count:2039 | 2039 |
| 690 | | - |
| 691 | | - |
| 692 | | - |
| 693 | return available; executed: return available;Execution Count:3730 | 3730 |
| 694 | } | - |
| 695 | | - |
| 696 | qint64 QProcessPrivate::readFromStdout(char *data, qint64 maxlen) | - |
| 697 | { | - |
| 698 | qint64 bytesRead = qt_safe_read(stdoutChannel.pipe[0], data, maxlen); | - |
| 699 | | - |
| 700 | | - |
| 701 | | - |
| 702 | | - |
| 703 | return bytesRead; executed: return bytesRead;Execution Count:46306 | 46306 |
| 704 | } | - |
| 705 | | - |
| 706 | qint64 QProcessPrivate::readFromStderr(char *data, qint64 maxlen) | - |
| 707 | { | - |
| 708 | qint64 bytesRead = qt_safe_read(stderrChannel.pipe[0], data, maxlen); | - |
| 709 | | - |
| 710 | | - |
| 711 | | - |
| 712 | | - |
| 713 | return bytesRead; executed: return bytesRead;Execution Count:359 | 359 |
| 714 | } | - |
| 715 | | - |
| 716 | qint64 QProcessPrivate::writeToStdin(const char *data, qint64 maxlen) | - |
| 717 | { | - |
| 718 | qint64 written = qt_safe_write_nosignal(stdinChannel.pipe[1], data, maxlen); | - |
| 719 | if (written == -1 && (*__errno_location ()) == 11) partially evaluated: written == -1| no Evaluation Count:0 | yes Evaluation Count:1175 |
never evaluated: (*__errno_location ()) == 11 | 0-1175 |
| 720 | written = 0; never executed: written = 0; | 0 |
| 721 | return written; executed: return written;Execution Count:1175 | 1175 |
| 722 | } | - |
| 723 | | - |
| 724 | void QProcessPrivate::terminateProcess() | - |
| 725 | { | - |
| 726 | | - |
| 727 | | - |
| 728 | | - |
| 729 | if (pid) evaluated: pid| yes Evaluation Count:115 | yes Evaluation Count:38 |
| 38-115 |
| 730 | ::kill(pid_t(pid), 15); executed: ::kill(pid_t(pid), 15);Execution Count:115 | 115 |
| 731 | } executed: }Execution Count:153 | 153 |
| 732 | | - |
| 733 | void QProcessPrivate::killProcess() | - |
| 734 | { | - |
| 735 | | - |
| 736 | | - |
| 737 | | - |
| 738 | if (pid) evaluated: pid| yes Evaluation Count:16 | yes Evaluation Count:3 |
| 3-16 |
| 739 | ::kill(pid_t(pid), 9); executed: ::kill(pid_t(pid), 9);Execution Count:16 | 16 |
| 740 | } executed: }Execution Count:19 | 19 |
| 741 | | - |
| 742 | static int select_msecs(int nfds, fd_set *fdread, fd_set *fdwrite, int timeout) | - |
| 743 | { | - |
| 744 | if (timeout < 0) evaluated: timeout < 0| yes Evaluation Count:17 | yes Evaluation Count:53058 |
| 17-53058 |
| 745 | return qt_safe_select(nfds, fdread, fdwrite, 0, 0); executed: return qt_safe_select(nfds, fdread, fdwrite, 0, 0);Execution Count:17 | 17 |
| 746 | | - |
| 747 | struct timeval tv; | - |
| 748 | tv.tv_sec = timeout / 1000; | - |
| 749 | tv.tv_usec = (timeout % 1000) * 1000; | - |
| 750 | return qt_safe_select(nfds, fdread, fdwrite, 0, &tv); executed: return qt_safe_select(nfds, fdread, fdwrite, 0, &tv);Execution Count:53058 | 53058 |
| 751 | } | - |
| 752 | | - |
| 753 | | - |
| 754 | | - |
| 755 | | - |
| 756 | | - |
| 757 | static int qt_timeout_value(int msecs, int elapsed) | - |
| 758 | { | - |
| 759 | if (msecs == -1) evaluated: msecs == -1| yes Evaluation Count:8 | yes Evaluation Count:50751 |
| 8-50751 |
| 760 | return -1; executed: return -1;Execution Count:8 | 8 |
| 761 | | - |
| 762 | int timeout = msecs - elapsed; | - |
| 763 | return timeout < 0 ? 0 : timeout; executed: return timeout < 0 ? 0 : timeout;Execution Count:50751 | 50751 |
| 764 | } | - |
| 765 | | - |
| 766 | bool QProcessPrivate::waitForStarted(int msecs) | - |
| 767 | { | - |
| 768 | QProcess * const q = q_func(); | - |
| 769 | | - |
| 770 | | - |
| 771 | | - |
| 772 | | - |
| 773 | | - |
| 774 | | - |
| 775 | fd_set fds; | - |
| 776 | do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fds)->fds_bits)[0]) : "memory"); } while (0); executed: }Execution Count:2316 partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:2316 |
| 0-2316 |
| 777 | (((&fds)->fds_bits)[((childStartedPipe[0]) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((childStartedPipe[0]) % (8 * (int) sizeof (__fd_mask))))); | - |
| 778 | if (select_msecs(childStartedPipe[0] + 1, &fds, 0, msecs) == 0) { partially evaluated: select_msecs(childStartedPipe[0] + 1, &fds, 0, msecs) == 0| no Evaluation Count:0 | yes Evaluation Count:2316 |
| 0-2316 |
| 779 | processError = QProcess::Timedout; | - |
| 780 | q->setErrorString(QProcess::tr("Process operation timed out")); | - |
| 781 | | - |
| 782 | | - |
| 783 | | - |
| 784 | return false; never executed: return false; | 0 |
| 785 | } | - |
| 786 | | - |
| 787 | bool startedEmitted = _q_startupNotification(); | - |
| 788 | | - |
| 789 | | - |
| 790 | | - |
| 791 | return startedEmitted; executed: return startedEmitted;Execution Count:2316 | 2316 |
| 792 | } | - |
| 793 | | - |
| 794 | bool QProcessPrivate::waitForReadyRead(int msecs) | - |
| 795 | { | - |
| 796 | QProcess * const q = q_func(); | - |
| 797 | | - |
| 798 | | - |
| 799 | | - |
| 800 | | - |
| 801 | QElapsedTimer stopWatch; | - |
| 802 | stopWatch.start(); | - |
| 803 | | - |
| 804 | for(;;) { | - |
| 805 | fd_set fdread; | - |
| 806 | fd_set fdwrite; | - |
| 807 | | - |
| 808 | do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fdread)->fds_bits)[0]) : "memory"); } while (0); executed: }Execution Count:709 partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:709 |
| 0-709 |
| 809 | do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fdwrite)->fds_bits)[0]) : "memory"); } while (0); executed: }Execution Count:709 partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:709 |
| 0-709 |
| 810 | | - |
| 811 | int nfds = deathPipe[0]; | - |
| 812 | (((&fdread)->fds_bits)[((deathPipe[0]) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((deathPipe[0]) % (8 * (int) sizeof (__fd_mask))))); | - |
| 813 | | - |
| 814 | if (processState == QProcess::Starting) evaluated: processState == QProcess::Starting| yes Evaluation Count:183 | yes Evaluation Count:526 |
| 183-526 |
| 815 | add_fd(nfds, childStartedPipe[0], &fdread); executed: add_fd(nfds, childStartedPipe[0], &fdread);Execution Count:183 | 183 |
| 816 | | - |
| 817 | if (stdoutChannel.pipe[0] != -1) evaluated: stdoutChannel.pipe[0] != -1| yes Evaluation Count:706 | yes Evaluation Count:3 |
| 3-706 |
| 818 | add_fd(nfds, stdoutChannel.pipe[0], &fdread); executed: add_fd(nfds, stdoutChannel.pipe[0], &fdread);Execution Count:706 | 706 |
| 819 | if (stderrChannel.pipe[0] != -1) evaluated: stderrChannel.pipe[0] != -1| yes Evaluation Count:484 | yes Evaluation Count:225 |
| 225-484 |
| 820 | add_fd(nfds, stderrChannel.pipe[0], &fdread); executed: add_fd(nfds, stderrChannel.pipe[0], &fdread);Execution Count:484 | 484 |
| 821 | | - |
| 822 | if (!writeBuffer.isEmpty() && stdinChannel.pipe[1] != -1) evaluated: !writeBuffer.isEmpty()| yes Evaluation Count:218 | yes Evaluation Count:491 |
partially evaluated: stdinChannel.pipe[1] != -1| yes Evaluation Count:218 | no Evaluation Count:0 |
| 0-491 |
| 823 | add_fd(nfds, stdinChannel.pipe[1], &fdwrite); executed: add_fd(nfds, stdinChannel.pipe[1], &fdwrite);Execution Count:218 | 218 |
| 824 | | - |
| 825 | int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); | - |
| 826 | int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); | - |
| 827 | if (ret < 0) { partially evaluated: ret < 0| no Evaluation Count:0 | yes Evaluation Count:709 |
| 0-709 |
| 828 | break; | 0 |
| 829 | } | - |
| 830 | if (ret == 0) { evaluated: ret == 0| yes Evaluation Count:6 | yes Evaluation Count:703 |
| 6-703 |
| 831 | processError = QProcess::Timedout; | - |
| 832 | q->setErrorString(QProcess::tr("Process operation timed out")); | - |
| 833 | return false; executed: return false;Execution Count:6 | 6 |
| 834 | } | - |
| 835 | | - |
| 836 | if (childStartedPipe[0] != -1 && ((((&fdread)->fds_bits)[((childStartedPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((childStartedPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) { evaluated: childStartedPipe[0] != -1| yes Evaluation Count:183 | yes Evaluation Count:520 |
evaluated: ((((&fdread)->fds_bits)[((childStartedPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((childStartedPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)| yes Evaluation Count:106 | yes Evaluation Count:77 |
| 77-520 |
| 837 | if (!_q_startupNotification()) evaluated: !_q_startupNotification()| yes Evaluation Count:101 | yes Evaluation Count:5 |
| 5-101 |
| 838 | return false; executed: return false;Execution Count:101 | 101 |
| 839 | } executed: }Execution Count:5 | 5 |
| 840 | | - |
| 841 | bool readyReadEmitted = false; | - |
| 842 | if (stdoutChannel.pipe[0] != -1 && ((((&fdread)->fds_bits)[((stdoutChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdoutChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) { evaluated: stdoutChannel.pipe[0] != -1| yes Evaluation Count:600 | yes Evaluation Count:2 |
evaluated: ((((&fdread)->fds_bits)[((stdoutChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdoutChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)| yes Evaluation Count:293 | yes Evaluation Count:307 |
| 2-600 |
| 843 | bool canRead = _q_canReadStandardOutput(); | - |
| 844 | if (processChannel == QProcess::StandardOutput && canRead) evaluated: processChannel == QProcess::StandardOutput| yes Evaluation Count:288 | yes Evaluation Count:5 |
evaluated: canRead| yes Evaluation Count:285 | yes Evaluation Count:3 |
| 3-288 |
| 845 | readyReadEmitted = true; executed: readyReadEmitted = true;Execution Count:285 | 285 |
| 846 | } executed: }Execution Count:293 | 293 |
| 847 | if (stderrChannel.pipe[0] != -1 && ((((&fdread)->fds_bits)[((stderrChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stderrChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) { evaluated: stderrChannel.pipe[0] != -1| yes Evaluation Count:378 | yes Evaluation Count:224 |
evaluated: ((((&fdread)->fds_bits)[((stderrChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stderrChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)| yes Evaluation Count:24 | yes Evaluation Count:354 |
| 24-378 |
| 848 | bool canRead = _q_canReadStandardError(); | - |
| 849 | if (processChannel == QProcess::StandardError && canRead) evaluated: processChannel == QProcess::StandardError| yes Evaluation Count:11 | yes Evaluation Count:13 |
partially evaluated: canRead| yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-13 |
| 850 | readyReadEmitted = true; executed: readyReadEmitted = true;Execution Count:11 | 11 |
| 851 | } executed: }Execution Count:24 | 24 |
| 852 | if (readyReadEmitted) evaluated: readyReadEmitted| yes Evaluation Count:296 | yes Evaluation Count:306 |
| 296-306 |
| 853 | return true; executed: return true;Execution Count:296 | 296 |
| 854 | | - |
| 855 | if (stdinChannel.pipe[1] != -1 && ((((&fdwrite)->fds_bits)[((stdinChannel.pipe[1]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdinChannel.pipe[1]) % (8 * (int) sizeof (__fd_mask))))) != 0)) partially evaluated: stdinChannel.pipe[1] != -1| yes Evaluation Count:306 | no Evaluation Count:0 |
evaluated: ((((&fdwrite)->fds_bits)[((stdinChannel.pipe[1]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdinChannel.pipe[1]) % (8 * (int) sizeof (__fd_mask))))) != 0)| yes Evaluation Count:218 | yes Evaluation Count:88 |
| 0-306 |
| 856 | _q_canWrite(); executed: _q_canWrite();Execution Count:218 | 218 |
| 857 | | - |
| 858 | if (deathPipe[0] == -1 || ((((&fdread)->fds_bits)[((deathPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((deathPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) { partially evaluated: deathPipe[0] == -1| no Evaluation Count:0 | yes Evaluation Count:306 |
evaluated: ((((&fdread)->fds_bits)[((deathPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((deathPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)| yes Evaluation Count:77 | yes Evaluation Count:229 |
| 0-306 |
| 859 | if (_q_processDied()) evaluated: _q_processDied()| yes Evaluation Count:2 | yes Evaluation Count:75 |
| 2-75 |
| 860 | return false; executed: return false;Execution Count:2 | 2 |
| 861 | } executed: }Execution Count:75 | 75 |
| 862 | } executed: }Execution Count:304 | 304 |
| 863 | return false; never executed: return false; | 0 |
| 864 | } | - |
| 865 | | - |
| 866 | bool QProcessPrivate::waitForBytesWritten(int msecs) | - |
| 867 | { | - |
| 868 | QProcess * const q = q_func(); | - |
| 869 | | - |
| 870 | | - |
| 871 | | - |
| 872 | | - |
| 873 | QElapsedTimer stopWatch; | - |
| 874 | stopWatch.start(); | - |
| 875 | | - |
| 876 | while (!writeBuffer.isEmpty()) { evaluated: !writeBuffer.isEmpty()| yes Evaluation Count:727 | yes Evaluation Count:3 |
| 3-727 |
| 877 | fd_set fdread; | - |
| 878 | fd_set fdwrite; | - |
| 879 | | - |
| 880 | do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fdread)->fds_bits)[0]) : "memory"); } while (0); executed: }Execution Count:727 partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:727 |
| 0-727 |
| 881 | do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fdwrite)->fds_bits)[0]) : "memory"); } while (0); executed: }Execution Count:727 partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:727 |
| 0-727 |
| 882 | | - |
| 883 | int nfds = deathPipe[0]; | - |
| 884 | (((&fdread)->fds_bits)[((deathPipe[0]) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((deathPipe[0]) % (8 * (int) sizeof (__fd_mask))))); | - |
| 885 | | - |
| 886 | if (processState == QProcess::Starting) partially evaluated: processState == QProcess::Starting| no Evaluation Count:0 | yes Evaluation Count:727 |
| 0-727 |
| 887 | add_fd(nfds, childStartedPipe[0], &fdread); never executed: add_fd(nfds, childStartedPipe[0], &fdread); | 0 |
| 888 | | - |
| 889 | if (stdoutChannel.pipe[0] != -1) partially evaluated: stdoutChannel.pipe[0] != -1| yes Evaluation Count:727 | no Evaluation Count:0 |
| 0-727 |
| 890 | add_fd(nfds, stdoutChannel.pipe[0], &fdread); executed: add_fd(nfds, stdoutChannel.pipe[0], &fdread);Execution Count:727 | 727 |
| 891 | if (stderrChannel.pipe[0] != -1) partially evaluated: stderrChannel.pipe[0] != -1| yes Evaluation Count:727 | no Evaluation Count:0 |
| 0-727 |
| 892 | add_fd(nfds, stderrChannel.pipe[0], &fdread); executed: add_fd(nfds, stderrChannel.pipe[0], &fdread);Execution Count:727 | 727 |
| 893 | | - |
| 894 | | - |
| 895 | if (!writeBuffer.isEmpty() && stdinChannel.pipe[1] != -1) partially evaluated: !writeBuffer.isEmpty()| yes Evaluation Count:727 | no Evaluation Count:0 |
partially evaluated: stdinChannel.pipe[1] != -1| yes Evaluation Count:727 | no Evaluation Count:0 |
| 0-727 |
| 896 | add_fd(nfds, stdinChannel.pipe[1], &fdwrite); executed: add_fd(nfds, stdinChannel.pipe[1], &fdwrite);Execution Count:727 | 727 |
| 897 | | - |
| 898 | int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); | - |
| 899 | int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); | - |
| 900 | if (ret < 0) { partially evaluated: ret < 0| no Evaluation Count:0 | yes Evaluation Count:727 |
| 0-727 |
| 901 | break; | 0 |
| 902 | } | - |
| 903 | | - |
| 904 | if (ret == 0) { partially evaluated: ret == 0| no Evaluation Count:0 | yes Evaluation Count:727 |
| 0-727 |
| 905 | processError = QProcess::Timedout; | - |
| 906 | q->setErrorString(QProcess::tr("Process operation timed out")); | - |
| 907 | return false; never executed: return false; | 0 |
| 908 | } | - |
| 909 | | - |
| 910 | if (childStartedPipe[0] != -1 && ((((&fdread)->fds_bits)[((childStartedPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((childStartedPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) { partially evaluated: childStartedPipe[0] != -1| no Evaluation Count:0 | yes Evaluation Count:727 |
never evaluated: ((((&fdread)->fds_bits)[((childStartedPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((childStartedPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0) | 0-727 |
| 911 | if (!_q_startupNotification()) never evaluated: !_q_startupNotification() | 0 |
| 912 | return false; never executed: return false; | 0 |
| 913 | } | 0 |
| 914 | | - |
| 915 | if (stdinChannel.pipe[1] != -1 && ((((&fdwrite)->fds_bits)[((stdinChannel.pipe[1]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdinChannel.pipe[1]) % (8 * (int) sizeof (__fd_mask))))) != 0)) partially evaluated: stdinChannel.pipe[1] != -1| yes Evaluation Count:727 | no Evaluation Count:0 |
partially evaluated: ((((&fdwrite)->fds_bits)[((stdinChannel.pipe[1]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdinChannel.pipe[1]) % (8 * (int) sizeof (__fd_mask))))) != 0)| yes Evaluation Count:727 | no Evaluation Count:0 |
| 0-727 |
| 916 | return _q_canWrite(); executed: return _q_canWrite();Execution Count:727 | 727 |
| 917 | | - |
| 918 | if (stdoutChannel.pipe[0] != -1 && ((((&fdread)->fds_bits)[((stdoutChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdoutChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) never evaluated: stdoutChannel.pipe[0] != -1 never evaluated: ((((&fdread)->fds_bits)[((stdoutChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdoutChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0) | 0 |
| 919 | _q_canReadStandardOutput(); never executed: _q_canReadStandardOutput(); | 0 |
| 920 | | - |
| 921 | if (stderrChannel.pipe[0] != -1 && ((((&fdread)->fds_bits)[((stderrChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stderrChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) never evaluated: stderrChannel.pipe[0] != -1 never evaluated: ((((&fdread)->fds_bits)[((stderrChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stderrChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0) | 0 |
| 922 | _q_canReadStandardError(); never executed: _q_canReadStandardError(); | 0 |
| 923 | | - |
| 924 | if (deathPipe[0] == -1 || ((((&fdread)->fds_bits)[((deathPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((deathPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) { never evaluated: deathPipe[0] == -1 never evaluated: ((((&fdread)->fds_bits)[((deathPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((deathPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0) | 0 |
| 925 | if (_q_processDied()) never evaluated: _q_processDied() | 0 |
| 926 | return false; never executed: return false; | 0 |
| 927 | } | 0 |
| 928 | } | 0 |
| 929 | | - |
| 930 | return false; executed: return false;Execution Count:3 | 3 |
| 931 | } | - |
| 932 | | - |
| 933 | bool QProcessPrivate::waitForFinished(int msecs) | - |
| 934 | { | - |
| 935 | QProcess * const q = q_func(); | - |
| 936 | | - |
| 937 | | - |
| 938 | | - |
| 939 | | - |
| 940 | QElapsedTimer stopWatch; | - |
| 941 | stopWatch.start(); | - |
| 942 | | - |
| 943 | for(;;) { | - |
| 944 | fd_set fdread; | - |
| 945 | fd_set fdwrite; | - |
| 946 | int nfds = -1; | - |
| 947 | | - |
| 948 | do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fdread)->fds_bits)[0]) : "memory"); } while (0); executed: }Execution Count:49323 partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:49323 |
| 0-49323 |
| 949 | do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fdwrite)->fds_bits)[0]) : "memory"); } while (0); executed: }Execution Count:49323 partially evaluated: 0| no Evaluation Count:0 | yes Evaluation Count:49323 |
| 0-49323 |
| 950 | | - |
| 951 | if (processState == QProcess::Starting) partially evaluated: processState == QProcess::Starting| no Evaluation Count:0 | yes Evaluation Count:49323 |
| 0-49323 |
| 952 | add_fd(nfds, childStartedPipe[0], &fdread); never executed: add_fd(nfds, childStartedPipe[0], &fdread); | 0 |
| 953 | | - |
| 954 | if (stdoutChannel.pipe[0] != -1) evaluated: stdoutChannel.pipe[0] != -1| yes Evaluation Count:47557 | yes Evaluation Count:1766 |
| 1766-47557 |
| 955 | add_fd(nfds, stdoutChannel.pipe[0], &fdread); executed: add_fd(nfds, stdoutChannel.pipe[0], &fdread);Execution Count:47557 | 47557 |
| 956 | if (stderrChannel.pipe[0] != -1) evaluated: stderrChannel.pipe[0] != -1| yes Evaluation Count:47608 | yes Evaluation Count:1715 |
| 1715-47608 |
| 957 | add_fd(nfds, stderrChannel.pipe[0], &fdread); executed: add_fd(nfds, stderrChannel.pipe[0], &fdread);Execution Count:47608 | 47608 |
| 958 | | - |
| 959 | if (processState == QProcess::Running) partially evaluated: processState == QProcess::Running| yes Evaluation Count:49323 | no Evaluation Count:0 |
| 0-49323 |
| 960 | add_fd(nfds, deathPipe[0], &fdread); executed: add_fd(nfds, deathPipe[0], &fdread);Execution Count:49323 | 49323 |
| 961 | | - |
| 962 | if (!writeBuffer.isEmpty() && stdinChannel.pipe[1] != -1) evaluated: !writeBuffer.isEmpty()| yes Evaluation Count:41 | yes Evaluation Count:49282 |
partially evaluated: stdinChannel.pipe[1] != -1| yes Evaluation Count:41 | no Evaluation Count:0 |
| 0-49282 |
| 963 | add_fd(nfds, stdinChannel.pipe[1], &fdwrite); executed: add_fd(nfds, stdinChannel.pipe[1], &fdwrite);Execution Count:41 | 41 |
| 964 | | - |
| 965 | int timeout = qt_timeout_value(msecs, stopWatch.elapsed()); | - |
| 966 | int ret = select_msecs(nfds + 1, &fdread, &fdwrite, timeout); | - |
| 967 | if (ret < 0) { partially evaluated: ret < 0| no Evaluation Count:0 | yes Evaluation Count:49323 |
| 0-49323 |
| 968 | break; | 0 |
| 969 | } | - |
| 970 | if (ret == 0) { evaluated: ret == 0| yes Evaluation Count:3 | yes Evaluation Count:49320 |
| 3-49320 |
| 971 | processError = QProcess::Timedout; | - |
| 972 | q->setErrorString(QProcess::tr("Process operation timed out")); | - |
| 973 | return false; executed: return false;Execution Count:3 | 3 |
| 974 | } | - |
| 975 | | - |
| 976 | if (childStartedPipe[0] != -1 && ((((&fdread)->fds_bits)[((childStartedPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((childStartedPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) { partially evaluated: childStartedPipe[0] != -1| no Evaluation Count:0 | yes Evaluation Count:49320 |
never evaluated: ((((&fdread)->fds_bits)[((childStartedPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((childStartedPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0) | 0-49320 |
| 977 | if (!_q_startupNotification()) never evaluated: !_q_startupNotification() | 0 |
| 978 | return false; never executed: return false; | 0 |
| 979 | } | 0 |
| 980 | if (stdinChannel.pipe[1] != -1 && ((((&fdwrite)->fds_bits)[((stdinChannel.pipe[1]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdinChannel.pipe[1]) % (8 * (int) sizeof (__fd_mask))))) != 0)) evaluated: stdinChannel.pipe[1] != -1| yes Evaluation Count:48519 | yes Evaluation Count:801 |
evaluated: ((((&fdwrite)->fds_bits)[((stdinChannel.pipe[1]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdinChannel.pipe[1]) % (8 * (int) sizeof (__fd_mask))))) != 0)| yes Evaluation Count:41 | yes Evaluation Count:48478 |
| 41-48519 |
| 981 | _q_canWrite(); executed: _q_canWrite();Execution Count:41 | 41 |
| 982 | | - |
| 983 | if (stdoutChannel.pipe[0] != -1 && ((((&fdread)->fds_bits)[((stdoutChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdoutChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) evaluated: stdoutChannel.pipe[0] != -1| yes Evaluation Count:47556 | yes Evaluation Count:1764 |
evaluated: ((((&fdread)->fds_bits)[((stdoutChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stdoutChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)| yes Evaluation Count:47093 | yes Evaluation Count:463 |
| 463-47556 |
| 984 | _q_canReadStandardOutput(); executed: _q_canReadStandardOutput();Execution Count:47093 | 47093 |
| 985 | | - |
| 986 | if (stderrChannel.pipe[0] != -1 && ((((&fdread)->fds_bits)[((stderrChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stderrChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) evaluated: stderrChannel.pipe[0] != -1| yes Evaluation Count:47607 | yes Evaluation Count:1713 |
evaluated: ((((&fdread)->fds_bits)[((stderrChannel.pipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((stderrChannel.pipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)| yes Evaluation Count:1956 | yes Evaluation Count:45651 |
| 1713-47607 |
| 987 | _q_canReadStandardError(); executed: _q_canReadStandardError();Execution Count:1956 | 1956 |
| 988 | | - |
| 989 | if (deathPipe[0] == -1 || ((((&fdread)->fds_bits)[((deathPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((deathPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)) { partially evaluated: deathPipe[0] == -1| no Evaluation Count:0 | yes Evaluation Count:49320 |
evaluated: ((((&fdread)->fds_bits)[((deathPipe[0]) / (8 * (int) sizeof (__fd_mask)))] & ((__fd_mask) 1 << ((deathPipe[0]) % (8 * (int) sizeof (__fd_mask))))) != 0)| yes Evaluation Count:1903 | yes Evaluation Count:47417 |
| 0-49320 |
| 990 | if (_q_processDied()) evaluated: _q_processDied()| yes Evaluation Count:1642 | yes Evaluation Count:261 |
| 261-1642 |
| 991 | return true; executed: return true;Execution Count:1642 | 1642 |
| 992 | } executed: }Execution Count:261 | 261 |
| 993 | } executed: }Execution Count:47678 | 47678 |
| 994 | return false; never executed: return false; | 0 |
| 995 | } | - |
| 996 | | - |
| 997 | bool QProcessPrivate::waitForWrite(int msecs) | - |
| 998 | { | - |
| 999 | fd_set fdwrite; | - |
| 1000 | do { int __d0, __d1; __asm__ __volatile__ ("cld; rep; " "stosq" : "=c" (__d0), "=D" (__d1) : "a" (0), "0" (sizeof (fd_set) / sizeof (__fd_mask)), "1" (&((&fdwrite)->fds_bits)[0]) : "memory"); } while (0); | 0 |
| 1001 | (((&fdwrite)->fds_bits)[((stdinChannel.pipe[1]) / (8 * (int) sizeof (__fd_mask)))] |= ((__fd_mask) 1 << ((stdinChannel.pipe[1]) % (8 * (int) sizeof (__fd_mask))))); | - |
| 1002 | return select_msecs(stdinChannel.pipe[1] + 1, 0, &fdwrite, msecs < 0 ? 0 : msecs) == 1; never executed: return select_msecs(stdinChannel.pipe[1] + 1, 0, &fdwrite, msecs < 0 ? 0 : msecs) == 1; | 0 |
| 1003 | } | - |
| 1004 | | - |
| 1005 | void QProcessPrivate::findExitCode() | - |
| 1006 | { | - |
| 1007 | QProcess * const q = q_func(); | - |
| 1008 | processManager()->remove(q); | - |
| 1009 | } executed: }Execution Count:4244 | 4244 |
| 1010 | | - |
| 1011 | bool QProcessPrivate::waitForDeadChild() | - |
| 1012 | { | - |
| 1013 | QProcess * const q = q_func(); | - |
| 1014 | | - |
| 1015 | | - |
| 1016 | char c; | - |
| 1017 | qt_safe_read(deathPipe[0], &c, 1); | - |
| 1018 | | - |
| 1019 | | - |
| 1020 | int exitStatus; | - |
| 1021 | if (qt_safe_waitpid(pid_t(pid), &exitStatus, 1) > 0) { evaluated: qt_safe_waitpid(pid_t(pid), &exitStatus, 1) > 0| yes Evaluation Count:1693 | yes Evaluation Count:1231 |
| 1231-1693 |
| 1022 | processManager()->remove(q); | - |
| 1023 | crashed = !((((*(int *) &(exitStatus))) & 0x7f) == 0); | - |
| 1024 | exitCode = ((((*(int *) &(exitStatus))) & 0xff00) >> 8); | - |
| 1025 | | - |
| 1026 | | - |
| 1027 | | - |
| 1028 | | - |
| 1029 | return true; executed: return true;Execution Count:1693 | 1693 |
| 1030 | } | - |
| 1031 | | - |
| 1032 | | - |
| 1033 | | - |
| 1034 | return false; executed: return false;Execution Count:1231 | 1231 |
| 1035 | } | - |
| 1036 | | - |
| 1037 | void QProcessPrivate::_q_notified() | - |
| 1038 | { | - |
| 1039 | } | - |
| 1040 | bool QProcessPrivate::startDetached(const QString &program, const QStringList &arguments, const QString &workingDirectory, qint64 *pid) | - |
| 1041 | { | - |
| 1042 | processManager()->start(); | - |
| 1043 | | - |
| 1044 | QByteArray encodedWorkingDirectory = QFile::encodeName(workingDirectory); | - |
| 1045 | | - |
| 1046 | | - |
| 1047 | int startedPipe[2]; | - |
| 1048 | qt_safe_pipe(startedPipe); | - |
| 1049 | | - |
| 1050 | int pidPipe[2]; | - |
| 1051 | qt_safe_pipe(pidPipe); | - |
| 1052 | | - |
| 1053 | pid_t childPid = fork(); | - |
| 1054 | if (childPid == 0) { partially evaluated: childPid == 0| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 1055 | struct sigaction noaction; | - |
| 1056 | memset(&noaction, 0, sizeof(noaction)); | - |
| 1057 | noaction.__sigaction_handler.sa_handler = ((__sighandler_t) 1); | - |
| 1058 | ::sigaction(13, &noaction, 0); | - |
| 1059 | | - |
| 1060 | ::setsid(); | - |
| 1061 | | - |
| 1062 | qt_safe_close(startedPipe[0]); | - |
| 1063 | qt_safe_close(pidPipe[0]); | - |
| 1064 | | - |
| 1065 | pid_t doubleForkPid = fork(); | - |
| 1066 | if (doubleForkPid == 0) { never evaluated: doubleForkPid == 0 | 0 |
| 1067 | qt_safe_close(pidPipe[1]); | - |
| 1068 | | - |
| 1069 | if (!encodedWorkingDirectory.isEmpty()) { never evaluated: !encodedWorkingDirectory.isEmpty() | 0 |
| 1070 | if (::chdir(encodedWorkingDirectory.constData()) == -1) never evaluated: ::chdir(encodedWorkingDirectory.constData()) == -1 | 0 |
| 1071 | QMessageLogger("io/qprocess_unix.cpp", 1365, __PRETTY_FUNCTION__).warning("QProcessPrivate::startDetached: failed to chdir to %s", encodedWorkingDirectory.constData()); never executed: QMessageLogger("io/qprocess_unix.cpp", 1365, __PRETTY_FUNCTION__).warning("QProcessPrivate::startDetached: failed to chdir to %s", encodedWorkingDirectory.constData()); | 0 |
| 1072 | } | 0 |
| 1073 | | - |
| 1074 | char **argv = new char *[arguments.size() + 2]; | - |
| 1075 | for (int i = 0; i < arguments.size(); ++i) never evaluated: i < arguments.size() | 0 |
| 1076 | argv[i + 1] = ::strdup(QFile::encodeName(arguments.at(i)).constData()); never executed: argv[i + 1] = ::strdup(QFile::encodeName(arguments.at(i)).constData()); | 0 |
| 1077 | argv[arguments.size() + 1] = 0; | - |
| 1078 | | - |
| 1079 | if (!program.contains(QLatin1Char('/'))) { never evaluated: !program.contains(QLatin1Char('/')) | 0 |
| 1080 | const QString path = QString::fromLocal8Bit(::getenv("PATH")); | - |
| 1081 | if (!path.isEmpty()) { never evaluated: !path.isEmpty() | 0 |
| 1082 | QStringList pathEntries = path.split(QLatin1Char(':')); | - |
| 1083 | for (int k = 0; k < pathEntries.size(); ++k) { never evaluated: k < pathEntries.size() | 0 |
| 1084 | QByteArray tmp = QFile::encodeName(pathEntries.at(k)); | - |
| 1085 | if (!tmp.endsWith('/')) tmp += '/'; never executed: tmp += '/'; never evaluated: !tmp.endsWith('/') | 0 |
| 1086 | tmp += QFile::encodeName(program); | - |
| 1087 | argv[0] = tmp.data(); | - |
| 1088 | qt_safe_execv(argv[0], argv); | - |
| 1089 | } | 0 |
| 1090 | } | 0 |
| 1091 | } else { | 0 |
| 1092 | QByteArray tmp = QFile::encodeName(program); | - |
| 1093 | argv[0] = tmp.data(); | - |
| 1094 | qt_safe_execv(argv[0], argv); | - |
| 1095 | } | 0 |
| 1096 | | - |
| 1097 | struct sigaction noaction; | - |
| 1098 | memset(&noaction, 0, sizeof(noaction)); | - |
| 1099 | noaction.__sigaction_handler.sa_handler = ((__sighandler_t) 1); | - |
| 1100 | ::sigaction(13, &noaction, 0); | - |
| 1101 | | - |
| 1102 | | - |
| 1103 | char c = '\1'; | - |
| 1104 | qt_safe_write(startedPipe[1], &c, 1); | - |
| 1105 | qt_safe_close(startedPipe[1]); | - |
| 1106 | ::_exit(1); | - |
| 1107 | } else if (doubleForkPid == -1) { never evaluated: doubleForkPid == -1 | 0 |
| 1108 | struct sigaction noaction; | - |
| 1109 | memset(&noaction, 0, sizeof(noaction)); | - |
| 1110 | noaction.__sigaction_handler.sa_handler = ((__sighandler_t) 1); | - |
| 1111 | ::sigaction(13, &noaction, 0); | - |
| 1112 | | - |
| 1113 | | - |
| 1114 | char c = '\2'; | - |
| 1115 | qt_safe_write(startedPipe[1], &c, 1); | - |
| 1116 | } | 0 |
| 1117 | | - |
| 1118 | qt_safe_close(startedPipe[1]); | - |
| 1119 | qt_safe_write(pidPipe[1], (const char *)&doubleForkPid, sizeof(pid_t)); | - |
| 1120 | if (::chdir("/") == -1) never evaluated: ::chdir("/") == -1 | 0 |
| 1121 | QMessageLogger("io/qprocess_unix.cpp", 1415, __PRETTY_FUNCTION__).warning("QProcessPrivate::startDetached: failed to chdir to /"); never executed: QMessageLogger("io/qprocess_unix.cpp", 1415, __PRETTY_FUNCTION__).warning("QProcessPrivate::startDetached: failed to chdir to /"); | 0 |
| 1122 | ::_exit(1); | - |
| 1123 | } | 0 |
| 1124 | | - |
| 1125 | qt_safe_close(startedPipe[1]); | - |
| 1126 | qt_safe_close(pidPipe[1]); | - |
| 1127 | | - |
| 1128 | if (childPid == -1) { partially evaluated: childPid == -1| no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
| 1129 | qt_safe_close(startedPipe[0]); | - |
| 1130 | qt_safe_close(pidPipe[0]); | - |
| 1131 | return false; never executed: return false; | 0 |
| 1132 | } | - |
| 1133 | | - |
| 1134 | char reply = '\0'; | - |
| 1135 | int startResult = qt_safe_read(startedPipe[0], &reply, 1); | - |
| 1136 | int result; | - |
| 1137 | qt_safe_close(startedPipe[0]); | - |
| 1138 | qt_safe_waitpid(childPid, &result, 0); | - |
| 1139 | bool success = (startResult != -1 && reply == '\0'); partially evaluated: startResult != -1| yes Evaluation Count:4 | no Evaluation Count:0 |
evaluated: reply == '\0'| yes Evaluation Count:2 | yes Evaluation Count:2 |
| 0-4 |
| 1140 | if (success && pid) { evaluated: success| yes Evaluation Count:2 | yes Evaluation Count:2 |
evaluated: pid| yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1-2 |
| 1141 | pid_t actualPid = 0; | - |
| 1142 | if (qt_safe_read(pidPipe[0], (char *)&actualPid, sizeof(pid_t)) == sizeof(pid_t)) { partially evaluated: qt_safe_read(pidPipe[0], (char *)&actualPid, sizeof(pid_t)) == sizeof(pid_t)| yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
| 1143 | *pid = actualPid; | - |
| 1144 | } else { executed: }Execution Count:1 | 1 |
| 1145 | *pid = 0; | - |
| 1146 | } | 0 |
| 1147 | } | - |
| 1148 | qt_safe_close(pidPipe[0]); | - |
| 1149 | return success; executed: return success;Execution Count:4 | 4 |
| 1150 | } | - |
| 1151 | | - |
| 1152 | | - |
| 1153 | void QProcessPrivate::initializeProcessManager() | - |
| 1154 | { | - |
| 1155 | (void) processManager(); | - |
| 1156 | } executed: }Execution Count:145 | 145 |
| 1157 | | - |
| 1158 | | - |
| 1159 | | - |
| 1160 | | - |
| | |