Magellan Linux

Contents of /trunk/slim/patches/slim-1.3.2-restart-xserver-if-killed.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1262 - (show annotations) (download)
Thu Jan 27 23:28:25 2011 UTC (13 years, 3 months ago) by niro
File size: 3198 byte(s)
added slim patches from upstream
1 Index: trunk/app.h
2 ===================================================================
3 --- trunk/app.h (revision 151)
4 +++ trunk/app.h (working copy)
5 @@ -34,6 +34,7 @@
6 ~App();
7 void Run();
8 int GetServerPID();
9 + void RestartServer();
10 void StopServer();
11
12 // Lock functions
13 @@ -48,7 +49,6 @@
14 void Console();
15 void Exit();
16 void KillAllClients(Bool top);
17 - void RestartServer();
18 void ReadConfig();
19 void OpenLog();
20 void CloseLog();
21 Index: trunk/app.cpp
22 ===================================================================
23 --- trunk/app.cpp (revision 151)
24 +++ trunk/app.cpp (working copy)
25 @@ -100,6 +100,11 @@
26
27 extern App* LoginApp;
28
29 +int xioerror(Display *disp) {
30 + LoginApp->RestartServer();
31 + return 0;
32 +}
33 +
34 void CatchSignal(int sig) {
35 cerr << APPNAME << ": unexpected signal " << sig << endl;
36 LoginApp->StopServer();
37 @@ -107,19 +112,6 @@
38 exit(ERR_EXIT);
39 }
40
41 -
42 -void AlarmSignal(int sig) {
43 - int pid = LoginApp->GetServerPID();
44 - if(waitpid(pid, NULL, WNOHANG) == pid) {
45 - LoginApp->StopServer();
46 - LoginApp->RemoveLock();
47 - exit(OK_EXIT);
48 - }
49 - signal(sig, AlarmSignal);
50 - alarm(2);
51 -}
52 -
53 -
54 void User1Signal(int sig) {
55 signal(sig, User1Signal);
56 }
57 @@ -257,7 +249,6 @@
58 signal(SIGHUP, CatchSignal);
59 signal(SIGPIPE, CatchSignal);
60 signal(SIGUSR1, User1Signal);
61 - signal(SIGALRM, AlarmSignal);
62
63 #ifndef XNEST_DEBUG
64 OpenLog();
65 @@ -277,7 +268,6 @@
66
67 CreateServerAuth();
68 StartServer();
69 - alarm(2);
70 #endif
71
72 }
73 @@ -575,6 +565,8 @@
74 int status;
75 while (wpid != pid) {
76 wpid = wait(&status);
77 + if (wpid == ServerPID)
78 + xioerror(Dpy); // Server died, simulate IO error
79 }
80 if (WIFEXITED(status) && WEXITSTATUS(status)) {
81 LoginPanel->Message("Failed to execute login command");
82 @@ -620,9 +612,6 @@
83
84
85 void App::Reboot() {
86 - // Stop alarm clock
87 - alarm(0);
88 -
89 #ifdef USE_PAM
90 try{
91 pam.end();
92 @@ -645,9 +634,6 @@
93
94
95 void App::Halt() {
96 - // Stop alarm clock
97 - alarm(0);
98 -
99 #ifdef USE_PAM
100 try{
101 pam.end();
102 @@ -733,6 +719,7 @@
103
104 StopServer();
105 RemoveLock();
106 + while (waitpid(-1, NULL, WNOHANG) > 0); // Collects all dead childrens
107 Run();
108 }
109
110 @@ -803,6 +790,7 @@
111
112 for(cycles = 0; cycles < ncycles; cycles++) {
113 if((Dpy = XOpenDisplay(DisplayName))) {
114 + XSetIOErrorHandler(xioerror);
115 return 1;
116 } else {
117 if(!ServerTimeout(1, "X server to begin accepting connections"))
118 @@ -885,9 +873,6 @@
119 ServerPID = -1;
120 break;
121 }
122 - alarm(15);
123 - pause();
124 - alarm(0);
125
126 // Wait for server to start up
127 if(WaitForServer() == 0) {
128 @@ -920,15 +905,12 @@
129
130
131 void App::StopServer() {
132 - // Stop alars clock and ignore signals
133 - alarm(0);
134 signal(SIGQUIT, SIG_IGN);
135 signal(SIGINT, SIG_IGN);
136 signal(SIGHUP, SIG_IGN);
137 signal(SIGPIPE, SIG_IGN);
138 signal(SIGTERM, SIG_DFL);
139 signal(SIGKILL, SIG_DFL);
140 - signal(SIGALRM, SIG_DFL);
141
142 // Catch X error
143 XSetIOErrorHandler(IgnoreXIO);