summaryrefslogtreecommitdiffstats
path: root/synchronizer
diff options
context:
space:
mode:
Diffstat (limited to 'synchronizer')
-rw-r--r--synchronizer/main.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/synchronizer/main.cpp b/synchronizer/main.cpp
index 11fec25..2b0cfe3 100644
--- a/synchronizer/main.cpp
+++ b/synchronizer/main.cpp
@@ -18,6 +18,7 @@
18 */ 18 */
19 19
20#include <QCoreApplication> 20#include <QCoreApplication>
21#include <QLockFile>
21 22
22#include <signal.h> 23#include <signal.h>
23 24
@@ -41,7 +42,16 @@ int main(int argc, char *argv[])
41 return app.exec(); 42 return app.exec();
42 } 43 }
43 44
44 Listener *listener = new Listener(argv[1], &app); 45 const QByteArray instanceIdentifier = argv[1];
46
47 QLockFile lockfile(instanceIdentifier + ".lock");
48 lockfile.setStaleLockTime(0);
49 if (!lockfile.tryLock(0)) {
50 Warning() << "Failed to acquire exclusive lock on socket.";
51 return -1;
52 }
53
54 Listener *listener = new Listener(instanceIdentifier, &app);
45 55
46 QObject::connect(&app, &QCoreApplication::aboutToQuit, 56 QObject::connect(&app, &QCoreApplication::aboutToQuit,
47 listener, &Listener::closeAllConnections); 57 listener, &Listener::closeAllConnections);