Add checking background service before connect (#716)
checking if the service is running for all platforms
This commit is contained in:
parent
d67c378bff
commit
ff348a348c
5 changed files with 20 additions and 4 deletions
|
@ -76,7 +76,7 @@ QString Utils::usrExecutable(const QString &baseName)
|
|||
return ("/usr/bin/" + baseName);
|
||||
}
|
||||
|
||||
bool Utils::processIsRunning(const QString &fileName)
|
||||
bool Utils::processIsRunning(const QString &fileName, const bool fullFlag)
|
||||
{
|
||||
#ifdef Q_OS_WIN
|
||||
QProcess process;
|
||||
|
@ -107,10 +107,14 @@ bool Utils::processIsRunning(const QString &fileName)
|
|||
#else
|
||||
QProcess process;
|
||||
process.setProcessChannelMode(QProcess::MergedChannels);
|
||||
process.start("pgrep", QStringList({ fileName }));
|
||||
process.start("pgrep", QStringList({ fullFlag ? "-f" : "", fileName }));
|
||||
process.waitForFinished();
|
||||
if (process.exitStatus() == QProcess::NormalExit) {
|
||||
return (process.readAll().toUInt() > 0);
|
||||
if (fullFlag) {
|
||||
return (process.readLine().toUInt() > 0);
|
||||
} else {
|
||||
return (process.readAll().toUInt() > 0);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue