mirror of
https://github.com/QuasarApp/Patronum.git
synced 2025-04-26 07:34:32 +00:00
fix PID file
This commit is contained in:
parent
d493203b20
commit
d1b866aeb2
@ -29,8 +29,9 @@ ServiceBase::ServiceBase(int argc, char *argv[]) {
|
||||
ServiceBase::~ServiceBase() {
|
||||
delete d_ptr;
|
||||
|
||||
QFile pidFile(PCommon::instance()->getPidfile());
|
||||
if (pidFile.exists()) {
|
||||
qint64 pid = PCommon::instance()->getPidFromPidfile();
|
||||
if (pid == QCoreApplication::applicationPid()) {
|
||||
QFile pidFile(PCommon::instance()->getPidfile());
|
||||
pidFile.remove();
|
||||
}
|
||||
|
||||
|
@ -19,11 +19,15 @@ QString PCommon::getPidfile() const {
|
||||
|
||||
qint64 PCommon::getPidFromPidfile() const {
|
||||
QFile file = getPidfile();
|
||||
|
||||
if (!file.exists())
|
||||
if (!file.open(QIODevice::ReadOnly)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
return file.readAll().toLongLong();
|
||||
auto data = file.readAll();
|
||||
|
||||
file.close();
|
||||
|
||||
return data.toLongLong();
|
||||
}
|
||||
|
||||
QString PCommon::getPWD() const {
|
||||
|
Loading…
x
Reference in New Issue
Block a user