Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [PATCH] [doc] clone module using xterm's slave mode



Stephane Chazelas wrote on Sun, 17 May 2020 11:13 +0100:
> Hi, while testing the patch for the pgrp restore issue, I came
> up with a way to clone zsh onto a xterm and attach to the tty
> device properly there (using xterm's slave mode).
> 
> Here's a doc patch to document that approach (requires socat,
> though the same could be done with expect or some perl/python
> pty module).
> 

Thanks!

> +++ b/Doc/Zsh/mod_clone.yo
> @@ -39,11 +39,30 @@ enditemize()
>  
>  This does not apply when cloning to an em(unused) vc.
>  
> +It is possible however to clone zsh onto a xterm and that zsh process
> +to lead the session attached to that terminal by using tt(xterm)'s slave
> +mode in conjunction with an utility like tt(socat) that can create a
> +pseudo-terminal pair:
>  
> +example(socat pty,link=pty,wait-slave,echo=0 'exec:xterm -Spty/3,nofork,fdout=3,fdin=3' &
> +        clone pty; (($!)) || { IFS= read -r WINDOWID && ((WINDOWID = 0x$WINDOWID));})

There's a race condition here («clone» might run before «./pty» is
created).  Is it worthwhile to point it out in the text, or add
a «sleep» in the example?

By the way, WDYT of adding a concept index entry (e.g., «cindex(tty,
cloning the shell onto an unused)») at the top of the file?  I think the
existing cindex entries won't help someone who doesn't know what the
module is called to discover it.

More later…

Cheers,

Daniel



Messages sorted by: Reverse Date, Date, Thread, Author