Check for duplicate NDNx Control Centers

Change-Id: I06d7aa71e1162e19f9fb38cada3c3c766b91cfd3
diff --git a/linux/tray-menu.cpp b/linux/tray-menu.cpp
index b6c405e..3dd006a 100644
--- a/linux/tray-menu.cpp
+++ b/linux/tray-menu.cpp
@@ -30,6 +30,12 @@
     QMainWindow(parent),
     ui(new Ui::TrayMenu)
 {
+    processLookup = new QProcess(this);
+    QStringList arguments;
+    arguments << "-al";
+    connect(processLookup,SIGNAL(finished(int)), this, SLOT(parseProcessLookup()));
+    processLookup->start("ps",arguments);
+
     networkManager = new NetworkManager();
 
     QCoreApplication::setOrganizationName("UCLA");
@@ -547,7 +553,18 @@
 }
 
 
+void TrayMenu::parseProcessLookup()
+{
+    QByteArray stdout = processLookup->readAllStandardOutput();
+    processLookup->deleteLater();
+     
+    QString s = QString(stdout);
 
+    if(s == "")
+      return;
+    else if(s.indexOf("ndnx-control") != s.lastIndexOf("ndnx-control"))
+      qApp->quit();
+}
 
 TrayMenu::~TrayMenu()
 {
diff --git a/linux/tray-menu.h b/linux/tray-menu.h
index 3a8110a..174e338 100644
--- a/linux/tray-menu.h
+++ b/linux/tray-menu.h
@@ -75,6 +75,7 @@
     QTimer *daemonStatusTimer;
     QThread *statusUpdateThread;
 
+    QProcess *processLookup;
     QProcess *applyStatusXslt;
     QProcess *applyFibXslt;
 
@@ -125,6 +126,7 @@
     void runXmlProc(QNetworkReply *reply);
     void parseStatusXml();
     void parseFibXml();
+    void parseProcessLookup();
 };
 
 #endif // TRAYMENU_H