| 245 | | void QProcessPrivate::startProcess() |
| 246 | | { |
| 247 | | Q_Q(QProcess); |
| 248 | | |
| 249 | | #if defined (QPROCESS_DEBUG) |
| 250 | | qDebug("QProcessPrivate::startProcess()"); |
| 251 | | #endif |
| 252 | | |
| 253 | | // Initialize pipes |
| 254 | | if (!createChannel(stdinChannel) || |
| 255 | | !createChannel(stdoutChannel) || |
| 256 | | !createChannel(stderrChannel)) |
| 257 | | return; |
| 258 | | |
| 259 | | // Start the process (platform dependent) |
| 260 | | q->setProcessState(QProcess::Starting); |
| 261 | | |
| 262 | | // save & copy the stdin socket |
| 263 | | int stdin_copy = ::dup(fileno(stdin)); |
| 264 | | ::dup2(stdinChannel.pipe[0], fileno(stdin)); |
| 265 | | |
| 266 | | // save & copy the stdout and stderr if asked to |
| 267 | | int stdout_copy = -1, stderr_copy = -1; |
| 268 | | if (processChannelMode != QProcess::ForwardedChannels) { |
| 269 | | stdout_copy = ::dup(fileno(stdout)); |
| 270 | | ::dup2(stdoutChannel.pipe[1], fileno(stdout)); |
| 271 | | |
| 272 | | // merge stdout and stderr if asked to |
| 273 | | stderr_copy = ::dup(fileno(stderr)); |
| 274 | | if (processChannelMode == QProcess::MergedChannels) { |
| 275 | | ::dup2(fileno(stdout), fileno(stderr)); |
| 276 | | } else { |
| 277 | | ::dup2(stderrChannel.pipe[1], fileno(stderr)); |
| 278 | | } |
| 279 | | } |
| | 245 | static int qt_startProcess(const QString &program, const QStringList &arguments, |
| | 246 | const QString &workingDirectory, |
| | 247 | const QStringList *environment, bool detached = false) |
| | 248 | { |
| | 249 | int mode = detached ? P_DETACH : P_NOWAIT; |