From 7dfc25002e52c4d944b39dcc52516af842dc2b11 Mon Sep 17 00:00:00 2001 From: Jay Sorg Date: Fri, 29 Nov 2013 15:20:50 -0800 Subject: X11rdp: wait for setxkbmap to finish --- xorg/X11R7.6/rdp/rdp.h | 2 ++ xorg/X11R7.6/rdp/rdpinput.c | 55 +++++++++++++++++++++++++++++++++++++++++++-- xorg/X11R7.6/rdp/rdpmisc.c | 10 +++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) (limited to 'xorg') diff --git a/xorg/X11R7.6/rdp/rdp.h b/xorg/X11R7.6/rdp/rdp.h index e493b281..7bc2eb6c 100644 --- a/xorg/X11R7.6/rdp/rdp.h +++ b/xorg/X11R7.6/rdp/rdp.h @@ -368,6 +368,8 @@ void RegionAroundSegs(RegionPtr reg, xSegment* segs, int nseg); int get_crc(char* data, int data_bytes); +int +get_mstime(void); /* rdpdraw.c */ Bool diff --git a/xorg/X11R7.6/rdp/rdpinput.c b/xorg/X11R7.6/rdp/rdpinput.c index 6f09ebe5..a2d7eac3 100644 --- a/xorg/X11R7.6/rdp/rdpinput.c +++ b/xorg/X11R7.6/rdp/rdpinput.c @@ -37,6 +37,8 @@ keyboard and mouse stuff /* this should be fixed in rdesktop */ #include "rdp.h" +#include +#include #define LOG_LEVEL 1 #define LLOG(_level, _args) \ @@ -546,6 +548,11 @@ rdpLoadLayout(int keylayout) char a7[16]; char a8[16]; int pid; + int rv; + int rv_pid; + int status; + int start_time; + int now_time; LLOGLN(10, ("rdpLoadLayout: keylayout 0x%8.8x display %s", keylayout, display)); @@ -585,13 +592,57 @@ rdpLoadLayout(int keylayout) LLOGLN(0, ("rdpLoadLayout: unknown keylayout 0x%8.8x", keylayout)); return 1; } + rv = 1; pid = fork(); - if (pid == 0) + if (pid == -1) { + LLOGLN(0, ("rdpLoadLayout: fork failed")); + return rv; + } + else if (pid == 0) + { + /* child */ execlp(a1, a2, a3, a4, a5, a6, a7, a8, (void *)0); exit(0); } - return 0; + else + { + /* parent */ + start_time = get_mstime(); + while (1) + { + usleep(1000); + rv_pid = waitpid(pid, &status, WNOHANG); + if (rv_pid == -1) + { + if (errno == EINTR) /* signal occurred */ + { + } + else + { + LLOGLN(0, ("rdpLoadLayout: waitpid failed")); + break; + } + } + else if (rv_pid == pid) + { + rv = 0; + LLOGLN(0, ("rdpLoadLayout: setxkbmap result %d", status)); + break; + } + else + { + LLOGLN(0, ("rdpLoadLayout: waitpid unknown pid return %d", rv)); + } + now_time = get_mstime(); + if (now_time - start_time > 1000 * 1000) + { + LLOGLN(0, ("rdpLoadLayout: waitpid timeout")); + break; + } + } + } + return rv; } /******************************************************************************/ diff --git a/xorg/X11R7.6/rdp/rdpmisc.c b/xorg/X11R7.6/rdp/rdpmisc.c index eb5bedad..1d57d1fa 100644 --- a/xorg/X11R7.6/rdp/rdpmisc.c +++ b/xorg/X11R7.6/rdp/rdpmisc.c @@ -668,3 +668,13 @@ get_crc(char* data, int data_bytes) CRC_END(crc); return crc; } + +/*****************************************************************************/ +int +get_mstime(void) +{ + struct timeval tp; + + gettimeofday(&tp, 0); + return (tp.tv_sec * 1000) + (tp.tv_usec / 1000); +} -- cgit v1.2.1