diff options
Diffstat (limited to 'xinit.c')
-rw-r--r-- | xinit.c | 62 |
1 files changed, 42 insertions, 20 deletions
@@ -106,30 +106,31 @@ static char *displayNum = NULL; static char *program = NULL; static Display *xd = NULL; /* server connection */ int status; -int serverpid = -1; -int clientpid = -1; +pid_t serverpid = -1; +pid_t clientpid = -1; #ifdef _F_LAUNCH_WM_AFTER_LAUNCHING_SERVER_ -int wmpid = -1; +pid_t wmpid = -1; #endif//_F_LAUNCH_WM_AFTER_LAUNCHING_SERVER_ volatile int gotSignal = 0; static void Execute(char **vec); static Bool waitforserver(void); -static Bool processTimeout(int timeout, char *string); -static int startServer(char *server[]); +static Bool processTimeout(int timeout, const char *string); +static pid_t startServer(char *server[]); +static pid_t startClient(char *client[]); #ifdef _F_LAUNCH_WM_AFTER_LAUNCHING_SERVER_ static void set_wm_user_groups(); -static int startWM(void); +static pid_t startWM(void); #endif//_F_LAUNCH_WM_AFTER_LAUNCHING_SERVER_ -static int startClient(char *client[]); + static int ignorexio(Display *dpy); static void shutdown(void); static void set_environment(void); -static void Fatal(const char *fmt, ...); -static void Error(const char *fmt, ...); -static void Fatalx(const char *fmt, ...); -static void Errorx(const char *fmt, ...); +static void Fatal(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN; +static void Error(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2); +static void Fatalx(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2) _X_NORETURN; +static void Errorx(const char *fmt, ...) _X_ATTRIBUTE_PRINTF(1,2); static void sigCatch(int sig) @@ -161,7 +162,7 @@ main(int argc, char *argv[]) register char **sptr = server; register char **cptr = client; register char **ptr; - int pid; + pid_t pid; int client_given = 0, server_given = 0; int client_args_given = 0, server_args_given = 0; int start_of_client_args, start_of_server_args; @@ -382,10 +383,11 @@ 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; + int i = 0; + pid_t pidfound = -1; + static const char *laststring; for (;;) { if ((pidfound = waitpid(serverpid, &status, WNOHANG)) == serverpid) @@ -406,7 +408,7 @@ processTimeout(int timeout, char *string) return (serverpid != pidfound); } -static int +static pid_t startServer(char *server[]) { sigset_t mask, old; @@ -542,7 +544,7 @@ set_wm_user_groups() setenv("HOME", cp, 1); } -static int +static pid_t startWM(void) { char *cp; @@ -672,7 +674,7 @@ setWindowPath(void) free(newwindowpath); } -static int +static pid_t startClient(char *client[]) { clientpid = fork(); @@ -745,6 +747,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 @@ -754,7 +776,7 @@ set_environment(void) Fatal("unable to set DISPLAY"); } -static void +static void _X_ATTRIBUTE_PRINTF(1,0) verror(const char *fmt, va_list ap) { fprintf(stderr, "%s: ", program); @@ -762,7 +784,7 @@ verror(const char *fmt, va_list ap) fprintf(stderr, ": %s\n", strerror(errno)); } -static void +static void _X_ATTRIBUTE_PRINTF(1,0) verrorx(const char *fmt, va_list ap) { fprintf(stderr, "%s: ", program); |