diff options
author | Alex Trotsenko <alex1973tr@gmail.com> | 2021-01-08 16:17:44 +0200 |
---|---|---|
committer | Alex Trotsenko <alex1973tr@gmail.com> | 2021-01-09 20:56:11 +0000 |
commit | 161e8f4d5dbaa568975d61d770144484e14a62e0 (patch) | |
tree | 394b92f0b462f0ea8788507ef625e49ba46e846c /src/corelib/io/qprocess.cpp | |
parent | 4ff41e6ff86b3f6a3a0ba215e9a3c8be19cf8055 (diff) |
QProcess/Win: clean up death notifier teardown
To avoid the mostly hypothetical possibility of failure, delete the
processFinishedNotifier before closing the handle on which it operates.
Previously, because of this, we explicitly disabled the notifier in the
processFinished() function, which made the code unclear. Now, we can
remove that safely, because cleanup() works correctly, and doing it
before calling findExitCode() was not necessary to start with.
Change-Id: Ia7095ded2c7eba8f4d738c6b87c7be41aa3cbbc8
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Diffstat (limited to 'src/corelib/io/qprocess.cpp')
-rw-r--r-- | src/corelib/io/qprocess.cpp | 20 |
1 files changed, 8 insertions, 12 deletions
diff --git a/src/corelib/io/qprocess.cpp b/src/corelib/io/qprocess.cpp index 48db7cdd54..9170b72e56 100644 --- a/src/corelib/io/qprocess.cpp +++ b/src/corelib/io/qprocess.cpp @@ -849,12 +849,6 @@ void QProcessPrivate::cleanup() { q_func()->setProcessState(QProcess::NotRunning); #ifdef Q_OS_WIN - if (pid) { - CloseHandle(pid->hThread); - CloseHandle(pid->hProcess); - delete pid; - pid = 0; - } if (stdinWriteTrigger) { delete stdinWriteTrigger; stdinWriteTrigger = 0; @@ -863,9 +857,15 @@ void QProcessPrivate::cleanup() delete processFinishedNotifier; processFinishedNotifier = 0; } - -#endif + if (pid) { + CloseHandle(pid->hThread); + CloseHandle(pid->hProcess); + delete pid; + pid = nullptr; + } +#else pid = 0; +#endif if (stdoutChannel.notifier) { delete stdoutChannel.notifier; @@ -1166,10 +1166,6 @@ void QProcessPrivate::processFinished() #ifdef Q_OS_UNIX waitForDeadChild(); #endif -#ifdef Q_OS_WIN - if (processFinishedNotifier) - processFinishedNotifier->setEnabled(false); -#endif findExitCode(); cleanup(); |