--- xorg-x11-apps-7.1/luit-1.0.1/luit.c.fix-race-condition 2006-10-02 15:23:34.000000000 -0400 +++ xorg-x11-apps-7.1/luit-1.0.1/luit.c 2006-10-02 15:30:48.000000000 -0400 @@ -54,6 +54,8 @@ int verbose = 0; int converter = 0; int exitOnChild = 0; +int readpipe = -1; +int writepipe = -1; volatile int sigwinch_queued = 0; volatile int sigchld_queued = 0; @@ -444,6 +446,7 @@ char *path; char **child_argv; int rc; + int p[2]; rc = parseArgs(argc, argv, child_argv0, &path, &child_argv); @@ -462,6 +465,15 @@ exit(1); } + rc = pipe(p); + if(rc < 0) { + perror("Couldn't create pipe"); + exit(1); + } + + readpipe = p[0]; + writepipe = p[1]; + pid = fork(); if(pid < 0) { perror("Couldn't fork"); @@ -486,7 +498,18 @@ { int tty; int pgrp; + int rc; + char c; + /* Wait until our parent has finished setting + * up the terminal. + */ + rc = read(readpipe, &c, 1); + if (rc < 0) { + perror("Could not read from pipe"); + exit(1); + } + close(0); close(1); close(2); @@ -535,6 +558,7 @@ int i; int val; int rc; + char c; if(verbose) { reportIso2022(outputState); @@ -564,6 +588,19 @@ setWindowSize(0, pty); + /* Inform the child that we have finished setting up the terminal. + * This is necessary since if the child is also changing the terminal + * settings, we might hang. + * + * See https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=197165 + */ + c = '!'; + rc = write(writepipe, &c, 1); + if(rc < 0) { + perror("Couldn't write to pipe"); + exit(1); + } + for(;;) { rc = waitForInput(0, pty);