mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-18 11:25:33 +08:00
Consume all console output of ping process, to avoid noise in test output.
This commit is contained in:
@@ -61,20 +61,20 @@ namespace BlackMisc
|
|||||||
bool CNetworkUtils::canPing(const QString &hostAddress)
|
bool CNetworkUtils::canPing(const QString &hostAddress)
|
||||||
{
|
{
|
||||||
if (hostAddress.isEmpty()) { return false; }
|
if (hostAddress.isEmpty()) { return false; }
|
||||||
QStringList params;
|
QProcess process;
|
||||||
|
process.setProgram("ping");
|
||||||
if (CBuildConfig::isRunningOnWindowsNtPlatform())
|
if (CBuildConfig::isRunningOnWindowsNtPlatform())
|
||||||
{
|
{
|
||||||
params << "-n" << "1";
|
process.setArguments({ "-n", "1", hostAddress });
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// all UNIX alike
|
// all UNIX alike
|
||||||
params << "-c" << "1";
|
process.setArguments({ "-c", "1", hostAddress });
|
||||||
}
|
}
|
||||||
params << hostAddress;
|
process.start();
|
||||||
|
process.waitForFinished();
|
||||||
const int exitCode = QProcess::execute("ping", params);
|
return process.exitCode() == 0;
|
||||||
return exitCode == 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CNetworkUtils::canPing(const CUrl &url)
|
bool CNetworkUtils::canPing(const CUrl &url)
|
||||||
|
|||||||
Reference in New Issue
Block a user