[PATCH luit] Set up terminal before fork.

Mike FABIAN mfabian at redhat.com
Mon Jan 7 23:54:13 PST 2013


Egbert Eich <eich at freedesktop.org> さんはかきました:

> From: Mike Fabian <mfabian at redhat.com>
>
> After the fork it is undefined wether parent or child runs
> first. So there can be a race: if the child runs before the
> terminal of the parent is set up correctly luit may hang.
> This patch sets up the terminal before forking and undoes
> the settings in the child.
>
> Signed-off-by: Egbert Eich <eich at freedesktop.org>

Signed-off-by: Mike FABIAN <mfabian at redhat.com>

> ---
>  luit.c |    7 ++++++-
>  1 files changed, 6 insertions(+), 1 deletions(-)
>
> diff --git a/luit.c b/luit.c
> index 0ece7b6..5cb3b8f 100644
> --- a/luit.c
> +++ b/luit.c
> @@ -577,6 +577,8 @@ condom(int argc, char **argv)
>  	IGNORE_RC(pipe(c2p_waitpipe));
>      }
>  
> +    setup_io(pty);
> +
>      pid = fork();
>      if (pid < 0) {
>  	perror("Couldn't fork");
> @@ -584,6 +586,10 @@ condom(int argc, char **argv)
>      }
>  
>      if (pid == 0) {
> +#ifdef SIGWINCH
> +	installHandler(SIGWINCH, SIG_DFL);
> +#endif
> +	installHandler(SIGCHLD, SIG_DFL);
>  	close(pty);
>  	if (pipe_option) {
>  	    close_waitpipe(1);
> @@ -661,7 +667,6 @@ parent(int pid GCC_UNUSED, int pty)
>      if (verbose) {
>  	reportIso2022(outputState);
>      }
> -    setup_io(pty);
>  
>      if (pipe_option) {
>  	write_waitpipe(p2c_waitpipe);

-- 
Mike FABIAN <mfabian at redhat.com>
☏ Office: +49-69-365051027, internal 8875027
睡眠不足はいい仕事の敵だ。


More information about the xorg-devel mailing list