42 lines
1.4 KiB
C++
42 lines
1.4 KiB
C++
/*
|
|
* Copyright (C) 2019 Tianjin KYLIN Information Technology Co., Ltd.
|
|
*
|
|
* This program is free software; you can redistribute it and/or modify
|
|
* it under the terms of the GNU Lesser General Public License as published by
|
|
* the Free Software Foundation; either version 2.1, or (at your option)
|
|
* any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful,
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
* GNU General Public License for more details.
|
|
*
|
|
* You should have received a copy of the GNU General Public License
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
*
|
|
*/
|
|
|
|
#include "snidaemon.h"
|
|
#include <ukui-log4qt.h>
|
|
#include <QApplication>
|
|
#include <QStandardPaths>
|
|
#include <QFile>
|
|
#include <fcntl.h>
|
|
#include <syslog.h>
|
|
|
|
int main(int argc, char *argv[])
|
|
{
|
|
initUkuiLog4qt("sni-daemon");
|
|
/*单例+vnc模式*/
|
|
QStringList homePath = QStandardPaths::standardLocations(QStandardPaths::HomeLocation);
|
|
int fd = open(QString(homePath.at(0) + "/.config/sni-daemon.lock").toUtf8().data(), O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR);
|
|
if (fd < 0) { exit(1); }
|
|
if (lockf(fd, F_TLOCK, 0)) {
|
|
syslog(LOG_ERR, "Can't lock single file, sni-daemon is already running!");
|
|
exit(0);
|
|
}
|
|
QApplication a(argc, argv);
|
|
SniDaemon w;
|
|
return a.exec();
|
|
}
|