From 1dd71b4eae433896e41f8366f23b8269712b4cf3 Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 18 Jul 2013 22:51:56 -0700 Subject: If we have to forcibly kill the Xserver on Solaris, reset kbd_mode MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If the Xserver hangs when xinit is waiting for it to die, and xinit sends a kill -9 to it, then it will leave the keyboard in a state that can't be used on the text console, so fix it up ourselves. Upstreaming from Solaris, where it was originally implemented to fix Sun bug 4221128 “If Xserver is slow to exit, xinit does "kill -9" and kbd_mode -a is required” Signed-off-by: Alan Coopersmith --- xinit.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'xinit.c') diff --git a/xinit.c b/xinit.c index 5310101..873b4fa 100644 --- a/xinit.c +++ b/xinit.c @@ -627,6 +627,26 @@ shutdown(void) if (processTimeout(3, "server to die")) Fatalx("X server refuses to die"); +#ifdef __sun + else { + /* Restore keyboard mode. */ + serverpid = fork(); + switch (serverpid) { + case 0: + execlp ("kbd_mode", "kbd_mode", "-a", NULL); + Fatal("Unable to run program \"%s\"", "kbd_mode"); + break; + + case 1: + Error("fork failed"); + break; + + default: + fprintf (stderr, "\r\nRestoring keyboard mode\r\n"); + processTimeout(1, "kbd_mode"); + } + } +#endif } static void -- cgit v1.2.3 From 09ab37f816d2fe9482574c825132d9b516b8e0bf Mon Sep 17 00:00:00 2001 From: Alan Coopersmith Date: Thu, 18 Jul 2013 22:58:10 -0700 Subject: Declare processTimeout() as taking a const string arg Fixes gcc const warnings on every call to it Signed-off-by: Alan Coopersmith --- xinit.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'xinit.c') diff --git a/xinit.c b/xinit.c index 873b4fa..eec4a2b 100644 --- a/xinit.c +++ b/xinit.c @@ -107,7 +107,7 @@ volatile int gotSignal = 0; static void Execute(char **vec); static Bool waitforserver(void); -static Bool processTimeout(int timeout, char *string); +static Bool processTimeout(int timeout, const char *string); static int startServer(char *server[]); static int startClient(char *client[]); static int ignorexio(Display *dpy); @@ -364,10 +364,10 @@ waitforserver(void) * return TRUE if we timeout waiting for pid to exit, FALSE otherwise. */ static Bool -processTimeout(int timeout, char *string) +processTimeout(int timeout, const char *string) { int i = 0, pidfound = -1; - static char *laststring; + static const char *laststring; for (;;) { if ((pidfound = waitpid(serverpid, &status, WNOHANG)) == serverpid) -- cgit v1.2.3