Introduce QProcessPrivate::closeChannels()
Avoid duplicating code for both platforms. Change-Id: Iae00023672b63e8539cf824fa3aaaff2bf9ae0c5 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
This commit is contained in:
parent
86542054d0
commit
64d6003f49
@ -834,9 +834,7 @@ void QProcessPrivate::cleanup()
|
||||
delete stateNotifier;
|
||||
stateNotifier = nullptr;
|
||||
}
|
||||
closeChannel(&stdoutChannel);
|
||||
closeChannel(&stderrChannel);
|
||||
closeChannel(&stdinChannel);
|
||||
closeChannels();
|
||||
destroyPipe(childStartedPipe);
|
||||
#ifdef Q_OS_UNIX
|
||||
if (forkfd != -1)
|
||||
@ -923,6 +921,16 @@ bool QProcessPrivate::openChannels()
|
||||
return true;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
void QProcessPrivate::closeChannels()
|
||||
{
|
||||
closeChannel(&stdoutChannel);
|
||||
closeChannel(&stderrChannel);
|
||||
closeChannel(&stdinChannel);
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
|
@ -326,6 +326,7 @@ public:
|
||||
#endif
|
||||
void closeChannel(Channel *channel);
|
||||
void closeWriteChannel();
|
||||
void closeChannels();
|
||||
bool tryReadFromChannel(Channel *channel); // obviously, only stdout and stderr
|
||||
|
||||
QString program;
|
||||
|
@ -885,9 +885,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
|
||||
|
||||
if (!openChannelsForDetached()) {
|
||||
// openChannel sets the error string
|
||||
closeChannel(&stdinChannel);
|
||||
closeChannel(&stdoutChannel);
|
||||
closeChannel(&stderrChannel);
|
||||
closeChannels();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -935,9 +933,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
|
||||
}
|
||||
|
||||
int savedErrno = errno;
|
||||
closeChannel(&stdinChannel);
|
||||
closeChannel(&stdoutChannel);
|
||||
closeChannel(&stderrChannel);
|
||||
closeChannels();
|
||||
|
||||
if (childPid == -1) {
|
||||
setErrorAndEmit(QProcess::FailedToStart, QLatin1String("fork: ") + qt_error_string(savedErrno));
|
||||
|
@ -905,9 +905,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
|
||||
|
||||
if (!openChannelsForDetached()) {
|
||||
// openChannel sets the error string
|
||||
closeChannel(&stdinChannel);
|
||||
closeChannel(&stdoutChannel);
|
||||
closeChannel(&stderrChannel);
|
||||
closeChannels();
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -955,9 +953,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
|
||||
setErrorAndEmit(QProcess::FailedToStart);
|
||||
}
|
||||
|
||||
closeChannel(&stdinChannel);
|
||||
closeChannel(&stdoutChannel);
|
||||
closeChannel(&stderrChannel);
|
||||
closeChannels();
|
||||
return success;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user