aboutsummaryrefslogtreecommitdiffstats
path: root/x11/slim/files/patch-002-fix-shutdown
blob: f2e27060844d19809635918c3f1d81ab68b28a2a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
------------------------------------------------------------------------
r169 | iwamatsu | 2009-11-14 09:13:57 +0100 (Sat, 14 Nov 2009) | 11 lines

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>
------------------------------------------------------------------------
--- app.h   (revision 168)
+++ app.h   (revision 169)
@@ -36,6 +36,7 @@
     int GetServerPID();
     void StopServer();
 
+   bool serverStarted;
     // Lock functions
     void GetLock();
     void RemoveLock();
--- app.cpp (revision 168)
+++ app.cpp (revision 169)
@@ -105,7 +105,10 @@
 
 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 @@
     int tmp;
     ServerPID = -1;
     testing = false;
+    serverStarted = false;
     mcookie = string(App::mcookiesize, 'a');
     daemonmode = false;
     force_nodaemon = false;
@@ -860,6 +864,8 @@
     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 @@
     
     delete args;
 
+    serverStarted = true;
+
     return ServerPID;
 }