Преглед на файлове

Add flag of server check

Slim gets this SIGTERM, and its signal handler calls
CloseServer() to teardown X. But X is not yet started (as StartServer()
is still running in another thread, waiting in pause()), and hence this
calls XcloseDisplay which frees some resources which are not yet allocated.

This parch fix this problem.
Thanks, Landry Breuil, goebbels, jasper and OpenBSD Developer.

Signed-off-by: Nobuhiro Iwamatsu <iwamatsu@nigauri.org>

git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/slim/trunk@169 7c53e7cc-98ea-0310-8f1f-a0b24da60408
iwamatsu преди 15 години
родител
ревизия
fc71102a30
променени са 2 файла, в които са добавени 10 реда и са изтрити 1 реда
  1. 9 1
      app.cpp
  2. 1 0
      app.h

+ 9 - 1
app.cpp

@@ -105,7 +105,10 @@ extern App* LoginApp;
 
 void CatchSignal(int sig) {
     cerr << APPNAME << ": unexpected signal " << sig << endl;
-    LoginApp->StopServer();
+
+    if (LoginApp->serverStarted)
+        LoginApp->StopServer();
+
     LoginApp->RemoveLock();
     exit(ERR_EXIT);
 }
@@ -140,6 +143,7 @@ App::App(int argc, char** argv)
     int tmp;
     ServerPID = -1;
     testing = false;
+    serverStarted = false;
     mcookie = string(App::mcookiesize, 'a');
     daemonmode = false;
     force_nodaemon = false;
@@ -860,6 +864,8 @@ int App::StartServer() {
     char* args = new char[argOption.length()+2]; // NULL plus vt
     strcpy(args, argOption.c_str());
 
+    serverStarted = false;
+
     int argc = 1;
     int pos = 0;
     bool hasVtSet = false;
@@ -940,6 +946,8 @@ int App::StartServer() {
     
     delete args;
 
+    serverStarted = true;
+
     return ServerPID;
 }
 

+ 1 - 0
app.h

@@ -36,6 +36,7 @@ public:
     int GetServerPID();
     void StopServer();
 
+	bool serverStarted;
     // Lock functions
     void GetLock();
     void RemoveLock();