From 743ffcbc822cc46c2b2d7cde6b6a3eca303d5c60 Mon Sep 17 00:00:00 2001 From: Dimitrios Apostolou Date: Thu, 10 Sep 2020 19:27:44 +0200 Subject: Avoid doing kill(-1) in QProcess destructor It can happen under unspecified conditions, see relevant ticket. Task-number: QTBUG-86285 Pick-to: 5.15 Change-Id: I1f77bf0061a0faaa60283bb93fc3d82031247d54 Reviewed-by: Thiago Macieira --- src/corelib/io/qprocess_unix.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 2c2f376028..1111e6e607 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -504,6 +504,7 @@ void QProcessPrivate::startProcess() } pid = qint64(childPid); + Q_ASSERT(pid > 0); // parent // close the ends we don't use and make all pipes non-blocking @@ -691,18 +692,18 @@ bool QProcessPrivate::writeToStdin() void QProcessPrivate::terminateProcess() { #if defined (QPROCESS_DEBUG) - qDebug("QProcessPrivate::terminateProcess()"); + qDebug("QProcessPrivate::terminateProcess() pid=%jd", intmax_t(pid)); #endif - if (pid) + if (pid > 0) ::kill(pid_t(pid), SIGTERM); } void QProcessPrivate::killProcess() { #if defined (QPROCESS_DEBUG) - qDebug("QProcessPrivate::killProcess()"); + qDebug("QProcessPrivate::killProcess() pid=%jd", intmax_t(pid)); #endif - if (pid) + if (pid > 0) ::kill(pid_t(pid), SIGKILL); } -- cgit v1.2.3