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;
|
delete stateNotifier;
|
||||||
stateNotifier = nullptr;
|
stateNotifier = nullptr;
|
||||||
}
|
}
|
||||||
closeChannel(&stdoutChannel);
|
closeChannels();
|
||||||
closeChannel(&stderrChannel);
|
|
||||||
closeChannel(&stdinChannel);
|
|
||||||
destroyPipe(childStartedPipe);
|
destroyPipe(childStartedPipe);
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
if (forkfd != -1)
|
if (forkfd != -1)
|
||||||
@ -923,6 +921,16 @@ bool QProcessPrivate::openChannels()
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
\internal
|
||||||
|
*/
|
||||||
|
void QProcessPrivate::closeChannels()
|
||||||
|
{
|
||||||
|
closeChannel(&stdoutChannel);
|
||||||
|
closeChannel(&stderrChannel);
|
||||||
|
closeChannel(&stdinChannel);
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\internal
|
\internal
|
||||||
*/
|
*/
|
||||||
|
@ -326,6 +326,7 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
void closeChannel(Channel *channel);
|
void closeChannel(Channel *channel);
|
||||||
void closeWriteChannel();
|
void closeWriteChannel();
|
||||||
|
void closeChannels();
|
||||||
bool tryReadFromChannel(Channel *channel); // obviously, only stdout and stderr
|
bool tryReadFromChannel(Channel *channel); // obviously, only stdout and stderr
|
||||||
|
|
||||||
QString program;
|
QString program;
|
||||||
|
@ -885,9 +885,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
|
|||||||
|
|
||||||
if (!openChannelsForDetached()) {
|
if (!openChannelsForDetached()) {
|
||||||
// openChannel sets the error string
|
// openChannel sets the error string
|
||||||
closeChannel(&stdinChannel);
|
closeChannels();
|
||||||
closeChannel(&stdoutChannel);
|
|
||||||
closeChannel(&stderrChannel);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -935,9 +933,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
|
|||||||
}
|
}
|
||||||
|
|
||||||
int savedErrno = errno;
|
int savedErrno = errno;
|
||||||
closeChannel(&stdinChannel);
|
closeChannels();
|
||||||
closeChannel(&stdoutChannel);
|
|
||||||
closeChannel(&stderrChannel);
|
|
||||||
|
|
||||||
if (childPid == -1) {
|
if (childPid == -1) {
|
||||||
setErrorAndEmit(QProcess::FailedToStart, QLatin1String("fork: ") + qt_error_string(savedErrno));
|
setErrorAndEmit(QProcess::FailedToStart, QLatin1String("fork: ") + qt_error_string(savedErrno));
|
||||||
|
@ -905,9 +905,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
|
|||||||
|
|
||||||
if (!openChannelsForDetached()) {
|
if (!openChannelsForDetached()) {
|
||||||
// openChannel sets the error string
|
// openChannel sets the error string
|
||||||
closeChannel(&stdinChannel);
|
closeChannels();
|
||||||
closeChannel(&stdoutChannel);
|
|
||||||
closeChannel(&stderrChannel);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -955,9 +953,7 @@ bool QProcessPrivate::startDetached(qint64 *pid)
|
|||||||
setErrorAndEmit(QProcess::FailedToStart);
|
setErrorAndEmit(QProcess::FailedToStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
closeChannel(&stdinChannel);
|
closeChannels();
|
||||||
closeChannel(&stdoutChannel);
|
|
||||||
closeChannel(&stderrChannel);
|
|
||||||
return success;
|
return success;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user