Commit 5603d29d by “liusq”

修改ping命令

parent f5f5f61d
......@@ -488,20 +488,21 @@ inline bool pingAddress(const QString &address) {
#ifdef Q_OS_WIN
// Windows 指令 "ping IP -n 1 -w 超时(ms)"
QString cmdstr = QString("ping %1 -n 1 -w %2")
.arg(address).arg(1000);
QStringList arguments;
arguments << "-c" << "ping " + address + " -n 1 -w 1000";
#else
// Linux 指令 "ping -c 1 IP"
QString cmdstr = QString("ping -c 1 %1")
.arg(address);
QStringList arguments;
arguments << "-c" << "ping -c 1 " + address;
#endif
// 启动进程
cmd.start(cmdstr);
cmd.start("bash", arguments);
// 等待进程准备好读取
if (!cmd.waitForStarted()) {
qWarning() << "Failed to start 'ping' process for" << address;
qWarning() << "无法启动的‘ping’进程" << address;
qWarning() << "命令: " << arguments.join(" ");
return false;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment