File p_bugzilla-117193-luit-sometimes-hangs.diff of Package xorg-x11

--- xc/programs/luit/luit.c	2004-12-04 18:42:05.000000000 +0100
+++ xc/programs/luit/luit.c	2005-09-28 17:26:35.000000000 +0200
@@ -434,6 +434,16 @@
     return 0;
 }
         
+static void
+sigwinchHandler(int sig) {
+    sigwinch_queued = 1;
+}
+
+static void
+sigchldHandler(int sig)
+{
+    sigchld_queued = 1;
+}
 
 static int
 condom(int argc, char **argv)
@@ -444,7 +454,8 @@
     char *path;
     char **child_argv;
     int rc;
-
+    int val;
+    
     rc = parseArgs(argc, argv, child_argv0,
                    &path, &child_argv);
     if(rc < 0)
@@ -461,6 +472,34 @@
         perror("Couldn't drop priviledges");
         exit(1);
     }
+    
+    if(verbose) {
+        reportIso2022(outputState);
+    }
+
+#ifdef SIGWINCH
+    installHandler(SIGWINCH, sigwinchHandler);
+#endif
+    installHandler(SIGCHLD, sigchldHandler);
+
+    rc = copyTermios(0, pty);
+    if(rc < 0)
+        FatalError("Couldn't copy terminal settings\n");
+
+    rc = setRawTermios();
+    if(rc < 0)
+        FatalError("Couldn't set terminal to raw\n");
+
+    val = fcntl(0, F_GETFL, 0);
+    if(val >= 0) {
+        fcntl(0, F_SETFL, val | O_NONBLOCK);
+    }
+    val = fcntl(pty, F_GETFL, 0);
+    if(val >= 0) {
+        fcntl(pty, F_SETFL, val | O_NONBLOCK);
+    }
+
+    setWindowSize(0, pty);
 
     pid = fork();
     if(pid < 0) {
@@ -517,53 +556,13 @@
     exit(1);
 }
 
-static void
-sigwinchHandler(int sig) {
-    sigwinch_queued = 1;
-}
-
-static void
-sigchldHandler(int sig)
-{
-    sigchld_queued = 1;
-}
-
 void
 parent(int pid, int pty)
 {
     unsigned char buf[BUFFER_SIZE];
     int i;
-    int val;
     int rc;
 
-    if(verbose) {
-        reportIso2022(outputState);
-    }
-
-#ifdef SIGWINCH
-    installHandler(SIGWINCH, sigwinchHandler);
-#endif
-    installHandler(SIGCHLD, sigchldHandler);
-
-    rc = copyTermios(0, pty);
-    if(rc < 0)
-        FatalError("Couldn't copy terminal settings\n");
-
-    rc = setRawTermios();
-    if(rc < 0)
-        FatalError("Couldn't set terminal to raw\n");
-
-    val = fcntl(0, F_GETFL, 0);
-    if(val >= 0) {
-        fcntl(0, F_SETFL, val | O_NONBLOCK);
-    }
-    val = fcntl(pty, F_GETFL, 0);
-    if(val >= 0) {
-        fcntl(pty, F_SETFL, val | O_NONBLOCK);
-    }
-
-    setWindowSize(0, pty);
-
     for(;;) {
         rc = waitForInput(0, pty);
 
openSUSE Build Service is sponsored by