mirror of
https://github.com/amnezia-vpn/amnezia-client.git
synced 2026-06-23 02:00:20 +07:00
bugfix: Correctly use QProcess::start and QProcess::execute (#1331)
Affected functions (all on Linux/Mac): - `RouterLinux::flushDns` was not reloading the DNS manager. - `Utils::processIsRunning` was always saying that the process is not running when `fullFlag` was set to `false`. - `Utils::killProcessByName` was not killing anything.
This commit is contained in:
committed by
GitHub
parent
6acaab0ffa
commit
a741186c21
@@ -194,8 +194,13 @@ bool Utils::processIsRunning(const QString &fileName, const bool fullFlag)
|
|||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
QProcess process;
|
QProcess process;
|
||||||
|
QStringList arguments;
|
||||||
|
if (fullFlag) {
|
||||||
|
arguments << "-f";
|
||||||
|
}
|
||||||
|
arguments << fileName;
|
||||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||||
process.start("pgrep", QStringList({ fullFlag ? "-f" : "", fileName }));
|
process.start("pgrep", arguments);
|
||||||
process.waitForFinished();
|
process.waitForFinished();
|
||||||
if (process.exitStatus() == QProcess::NormalExit) {
|
if (process.exitStatus() == QProcess::NormalExit) {
|
||||||
if (fullFlag) {
|
if (fullFlag) {
|
||||||
@@ -248,7 +253,7 @@ bool Utils::killProcessByName(const QString &name)
|
|||||||
#elif defined Q_OS_IOS || defined(Q_OS_ANDROID)
|
#elif defined Q_OS_IOS || defined(Q_OS_ANDROID)
|
||||||
return false;
|
return false;
|
||||||
#else
|
#else
|
||||||
return QProcess::execute(QString("pkill %1").arg(name)) == 0;
|
return QProcess::execute("pkill", { name }) == 0;
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -162,11 +162,11 @@ void RouterLinux::flushDns()
|
|||||||
|| QFileInfo::exists("/usr/sbin/nscd")
|
|| QFileInfo::exists("/usr/sbin/nscd")
|
||||||
|| QFileInfo::exists("/usr/lib/systemd/system/nscd.service"))
|
|| QFileInfo::exists("/usr/lib/systemd/system/nscd.service"))
|
||||||
{
|
{
|
||||||
p.start("systemctl restart nscd");
|
p.start("systemctl", { "restart", "nscd" });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
p.start("systemctl restart systemd-resolved");
|
p.start("systemctl", { "restart", "systemd-resolved" });
|
||||||
}
|
}
|
||||||
|
|
||||||
p.waitForFinished();
|
p.waitForFinished();
|
||||||
|
|||||||
Reference in New Issue
Block a user