Qnx: Merge qnxdeviceprocesssignaloperation.{h,cpp} into qnxdevice.cpp

Not worth a file pair anymore.

Change-Id: I86afff84586592dd05d40e573e6b9a95c54913fe
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2023-03-13 15:03:33 +01:00
parent 72e2df0c95
commit 4f8ad43c1e
5 changed files with 31 additions and 62 deletions

View File

@@ -11,7 +11,6 @@ add_qtc_plugin(Qnx
qnxdeployqtlibrariesdialog.cpp qnxdeployqtlibrariesdialog.h
qnxdevice.cpp qnxdevice.h
qnxdeviceprocesslist.cpp qnxdeviceprocesslist.h
qnxdeviceprocesssignaloperation.cpp qnxdeviceprocesssignaloperation.h
qnxdevicetester.cpp qnxdevicetester.h
qnxdevicewizard.cpp qnxdevicewizard.h
qnxplugin.cpp

View File

@@ -32,8 +32,6 @@ QtcPlugin {
"qnxdevicewizard.h",
"qnxdeviceprocesslist.cpp",
"qnxdeviceprocesslist.h",
"qnxdeviceprocesssignaloperation.cpp",
"qnxdeviceprocesssignaloperation.h",
"qnxdevicetester.cpp",
"qnxdevicetester.h",
"qnxconfigurationmanager.cpp",

View File

@@ -7,10 +7,11 @@
#include "qnxdeployqtlibrariesdialog.h"
#include "qnxdevicetester.h"
#include "qnxdeviceprocesslist.h"
#include "qnxdeviceprocesssignaloperation.h"
#include "qnxdevicewizard.h"
#include "qnxtr.h"
#include <remotelinux/remotelinuxsignaloperation.h>
#include <utils/port.h>
#include <utils/qtcassert.h>
#include <utils/qtcprocess.h>
@@ -25,6 +26,35 @@ namespace Qnx::Internal {
const char QnxVersionKey[] = "QnxVersion";
static QString signalProcessByNameQnxCommandLine(const QString &filePath, int sig)
{
QString executable = filePath;
return QString::fromLatin1("for PID in $(ps -f -o pid,comm | grep %1 | awk '/%1/ {print $1}'); "
"do "
"kill -%2 $PID; "
"done").arg(executable.replace(QLatin1String("/"), QLatin1String("\\/"))).arg(sig);
}
class QnxDeviceProcessSignalOperation : public RemoteLinuxSignalOperation
{
public:
explicit QnxDeviceProcessSignalOperation(const IDeviceConstPtr &device)
: RemoteLinuxSignalOperation(device)
{}
QString killProcessByNameCommandLine(const QString &filePath) const override
{
return QString::fromLatin1("%1; %2").arg(signalProcessByNameQnxCommandLine(filePath, 15),
signalProcessByNameQnxCommandLine(filePath, 9));
}
QString interruptProcessByNameCommandLine(const QString &filePath) const override
{
return signalProcessByNameQnxCommandLine(filePath, 2);
}
};
QnxDevice::QnxDevice()
{
setDisplayType(Tr::tr("QNX"));

View File

@@ -1,36 +0,0 @@
// Copyright (C) 2016 BlackBerry Limited. All rights reserved.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qnxdeviceprocesssignaloperation.h"
namespace Qnx::Internal {
QnxDeviceProcessSignalOperation::QnxDeviceProcessSignalOperation(
const ProjectExplorer::IDeviceConstPtr &device)
: RemoteLinux::RemoteLinuxSignalOperation(device)
{
}
static QString signalProcessByNameQnxCommandLine(const QString &filePath, int sig)
{
QString executable = filePath;
return QString::fromLatin1("for PID in $(ps -f -o pid,comm | grep %1 | awk '/%1/ {print $1}'); "
"do "
"kill -%2 $PID; "
"done").arg(executable.replace(QLatin1String("/"), QLatin1String("\\/"))).arg(sig);
}
QString QnxDeviceProcessSignalOperation::killProcessByNameCommandLine(
const QString &filePath) const
{
return QString::fromLatin1("%1; %2").arg(signalProcessByNameQnxCommandLine(filePath, 15),
signalProcessByNameQnxCommandLine(filePath, 9));
}
QString QnxDeviceProcessSignalOperation::interruptProcessByNameCommandLine(
const QString &filePath) const
{
return signalProcessByNameQnxCommandLine(filePath, 2);
}
} // Qnx::Internal

View File

@@ -1,22 +0,0 @@
// Copyright (C) 2016 BlackBerry Limited. All rights reserved.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#pragma once
#include <remotelinux/remotelinuxsignaloperation.h>
namespace Qnx::Internal {
class QnxDeviceProcessSignalOperation : public RemoteLinux::RemoteLinuxSignalOperation
{
protected:
explicit QnxDeviceProcessSignalOperation(const ProjectExplorer::IDeviceConstPtr &device);
private:
QString killProcessByNameCommandLine(const QString &filePath) const override;
QString interruptProcessByNameCommandLine(const QString &filePath) const override;
friend class QnxDevice;
};
} // Qnx::Internal