Browse Source

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

+ 1 - 0
app.h

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